The news of the time interval is that Python is going to remove some standard library modules ( via ). This news caught my eye because two of the modules to be removed are
cgi
and its closely related kin
cgitb
. We have a number of little CGIs in our environment for internal use, and many of them are written in Python, so I expected to find us using
cgi
all over the place. When I actually looked, our usage was much lower than I expected, except for one thing.
Some of our CGIs are purely informational; they present some dynamic information on a web page, and don't take any parameters or otherwise particularly interact with people. These CGIs tend to use
cgitb
so that if they have bugs, we have some hope of catching things. When these CGIs were written,
cgitb
was the easy way to do something, but these days I would log tracebacks to syslog using my good way to format them .
(It will probably surprise no one that in the twelve years since I wrote that entry , none of our internal CGIs were changed away from using
cgitb
. Inertia is an extremely powerful force.)
Others of our CGIs are interactive, such as the CGIs we use for our self-serve network access registration systems . These CGIs need to extract information from submitted forms, so of course they use the ever-popular
cgi.FieldStorage
class. As far as I know there is and will be no standard library replacement for this, so in theory we will have to do something here. Since we don't want file uploads, it actually isn't that much work to read and parse a standard
POST
body, or we could just keep our own copy of
cgi.py
and use it in perpetuity.
(The real answer is that all of these CGIs are still Python 2 and are probably going to stay that way, with them running under PyPy if it becomes necessary because Ubuntu removes Python 2 entirely someday.)
PS: DWiki , the pile of Python that is rendering Wandering Thoughts for you to read, has its own code to handle
GET
parameters and
POST
forms, which is why I know that doing that isn't too much work. A very long time ago DWiki did use
cgi.FieldStorage
and I had some problems as a result , but that got entirely rewritten when I moved DWiki to being based on WSGI .