If Not CGI...
Tim Chase
python.list at tim.thechases.com
Sat Jun 19 14:56:41 EDT 2010
> I've caught a lot of flack (imagine that) about using CGI.
The main reason is that CGI has the overhead of loading &
unloading the Python interpreter on every request. The other
methods load the Python interpreter once (or a small,
fixed-number of times), then handle lots of requests from that
process (or pool of processes), and then optionally unload if
server-load drops.
However CGI is old and fairly entrenched, so it's easy to find
with cheap hosting services -- what do they care if your site is
slow?
> I understand there are several other options, to wit:
> mod_python, fastcgi and wcgi. I've messed around with
> mod_python without luck. What are your suggestions?
Generally, one writes to a framework (Django[1], web.py[2],
TurboGears[3], CherryPy[4], etc) that either has a
preferred/suggested method of interface, or allows you to plug
into [m]any of the items you list. I know Django is happy with
mod_python and wsgi (and I suspect fastcgi, but I'll let you
google that). YMMV with the others. I've even seen an
abomination of a hack that ran Django under CGI (whooooie, is the
performance bad!). I think the general direction of the Python
web-world seems to be moving toward WSGI (and Graham Dumpleton's
work on mod_wsgi[5]; IIUC, he was heavily involved in the initial
mod_python) instead of mod_python.
Since you seem fairly adamant about *not* using a framework and
cobbling together the universe from the ground up, you might look
into Paul Boddie's "WebStack"[6] which abstracts away a number of
the main interfaces into a common interface. Kindly, his work
even allows you to plug into a CGI interface since that's what
you're familiar with, and then shift to a different interface.
-tkc
[1]
http://djangoproject.com
[2]
http://turbogears.org
[3]
http://webpy.org
[4]
http://www.cherrypy.org
[5]
http://code.google.com/p/modwsgi/
[6]
http://www.boddie.org.uk/python/WebStack.html
More information about the Python-list
mailing list