Pythonic way of web-programming

Alex Martelli aleax at
Tue Apr 15 10:11:13 CEST 2003

Andy Robinson wrote:
> First, let's note the half-a-dozen different templating schemes
> available.  DTML, Woven, Quixote, YAPTU, preppy.

YAPTU's a toy -- and, as its author, I hope I can assert that with
some credibility!-)  Cheetah, OTOH, is a serious contender for the
"best of breed" Python templating utility (at least when templates
need to be maintained by non-programmers).  I don't know if it's
entirely correct to describe Quixote as a templating tool.  Rather,
I _would_ count such packages as Spyce...

None of this invalidates your main point, of course (indeed, on
the contrary, it might reinforce it).

> be wonderful if this could be systematized in something like the 'db
> api', with some interfaces defined in the standard Python library.

The DB API isn't in the standard library (and until some substantial
amount of reusable CODE is factored out, rather than just somewhat
vague interface specs, I doubt it will be... or _should_ be).  If a
consensus could be reached among a sufficient number of the maintainers
of existing packages, then, sure, some interfaces could be standardized.

However -- look at the XML situation for contrast.  There IS just such
a standard (and parts of it ARE in the standard libraries, while others,
PyXML stuff, integrate as seamlessly as they can with those via some
import tricks).  AND YET -- you guys have developed and maintain PyRXP,
which uses substantially different interfaces -- *AND WELL IT DOES*,
because thanks to the different interfaces (trees of bare tuples, or
lists as the case may be, rather than intricate objects as in DOM) it
can save a LOT of memory, and generally zip along much, much faster.

Aren't there analogies here...?  preppy may be the simplest (and thus,
the best) templating tool for a Python programmer -- starting with a
good knowledge of Python, said programmer needs to learn very little to
start using preppy.  Yet Cheetah's very different templating language
may be best if one needs templates to be handled with 3rd party tools
designed to handle HTML pages, and more generally maintained by people
who do not consider themselves programmers and might strongly resist
"having to learn to program".  Targeting different audiences, is it
surprising that preppy and Cheetah end up with so different interfaces?

> Finally, there's a transport mechanism.  Here one could use
> CGI, Twisted, Zope, BaseHTTPServer or whatever else.

Not sure I'd qualify Zope as a "transport" mechanism!-)  Rather
the choice here is:

  -- a custom server program coded in Python (BaseHTTPServer and
     the like, Medusa, Twisted)

  -- CGI, the only standard ensuring operability with different
     webservers (maybe fast-CGI might live here too...?)

  -- webserver-specific ways to cooperate with existing webservers:
     LRWP for Xitami, mod_python or mod_webkit or PyApache for
     Apache, ASP or lower-level interfaces to MS servers, ...

Can we find enough commonality among such disparate needs to
extract out some common interfaces?  In the DB-API case (and in
the XML one) there were some existing external standards (not
necessarily well-observed, vide the SQL standard, but still maybe
better than nothing) as a reference point.  Besides CGI, and
HTTP itself, what would we build upon here?  Perhaps the Request-
Response model you mention would suffice for reasonably high
level interactions, but much of what one can do e.g. with mod_python
ISN'T "reasonably high level" (or else one would just use
PyApache for CGI-substition-level tasks...!).

> Wouldn't it be nice if one day we could have some standardized
> interfaces, so that one could switch between these without undue pain
> and reduce the confusion people must face?

Yes, it would be VERY nice, but I have no idea about how to make
it happen, or even about how it would look like if it ever did.


More information about the Python-list mailing list