[mod_python] Leaking and cgi-handler
Danilo Fiorenzano
danilo at telusplanet.net
Wed Jun 7 14:51:44 EST 2000
Gregory Trubetskoy <grisha at modpython.org> writes:
> The cgihandler when used with scripts not using cgi.py does not leak a
> byte of memory. Unfortunately 98% of Python scripts out there start with
> "import cgi".
..
> My recomendation would to rewrite everything using "native" mod_python
> handlers. They are simple (much simpler than CGI), fast and they do not
> leak memory. You fears about them being unstable are unfounded, I think.
On this theme: from the heights of my blissful ignorance (started
learning python and its library 2 weeks ago or so), I apparently
devised a way to use the facilities of the cgi module with mod_python
_without_ using the cgihandler. I do something like this:
import cgi
from mod_python import apache
def handler(req):
req.content_type = "text/html"
req.send_http_header()
env, si, so = apache.setup_cgi(req)
formData = cgi.FieldStorage()
for key in formData.keys():
req.write( str(key) + " : " + str(data[key].value) + "<br>" )
This works without the need to specify cgihandler in the apache
config. Not sure whether it's the Right way to handle things, or if
it avoids the leaking, but I thought it was worth sharing.. YMMV.
regards
-- Danilo
More information about the Mod_python
mailing list