Python / web
mwm at mired.org
Fri Sep 2 05:43:35 CEST 2005
Robert <rjr at nowhere.net> writes:
> I know general Python pretty well and interested in using Python for a
> web project. It will have the standard display, user input, fields,
> look-ups, reports, database routines, etc..... Been looking though the
> Python web docs. and seeing stuff like mod_python, CGI, PSP, CherryPy,
> etc..., Also a fair amount of googling. I'll say there's a large
> amount of technology to pick from. Rather than spend time going down
> the wrong road, can I get some feedback as directions from you folks
> that's "been there, done that."
Well, as usual when answering such questions, the answer is "It
depends." If you're interested in getting a web site up with a
Python-like tool, then you want a framework. Others have already
suggested Zope/Plone, which seems to be the most popular such
system. I only have limit experience with Zope, but I found that it
tended to own the resulting code, such that reusing it in another
framework would be a PITA.
If you're more interested in working in Python, with a cleaner
representation of the HTML than as Python strings with %()'s scattered
through them, then you want a templating systems. I recently evaluated
a number of templating systems for a client, and we settled on
Cheetah. The reasons for this were:
1) Cheetah is not just a web templating language; it can be
used for anything. My first Cheetah template generated XML
to feed to an XMLHttpRequest.
2) Cheetah templates compile to Python classes, so anything I
can use to hook Python up to my web server I can use with Cheetah
3) Cheetah constructs don't try and look like HTML. This
means less typing to use them, and they won't cause problems
with whatever HTML/XML-aware editor you may want to use.
In refernce to the "owning" affect above, all the real work on our
pages is done in pure Python classes that the Cheetah templates
inherit from. So we can remove the dependency on Cheetah by changing
one fixed line in each file to a different line - which change can be
Mike Meyer <mwm at mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
More information about the Python-list