append to non-existing list

Mike Meyer mwm at mired.org
Thu Nov 10 16:00:41 EST 2005


Yves Glodt <y.glodt at sitasoftware.lu> writes:
> Which raises another question... :-)
>
> Is there a possibility to bring together apache and python in a way
> that I can embed python into html?

Lots of ways. Most of them aren't really Python, but look a lot like
it.

PSP is most like PHP/ASP/etc., and I believe current mod_python's come
with a PSP processor. Be warned that there's more than one thing
floating around by the name Python Server Pages, and they aren't
completely compatible.

Personally, I prefer Cheetah for this, for three reasons:

1) Cheetah doesn't use X/HTML-like syntax for it's tags, so they don't
interfere with my intelligent X/HTML tools.

2) Cheetah can be used for things other than X/HTML, so you get a
twofer on tools. For my last project, I created the Makefile from a
Cheetah template.

3) Cheetah templates are Classes, so you inherit from them. The same
last project created a top-level template that did the site-wide
banner/nav/etc things, and defined abstracd methods for the
title/content. Pages inherited from that (or in some cases from a
subclass of that) and defined concrete versions of the abstrat
methods. Cheetah templates can inherit from Python classes (which I've
found useful), and Python classes can inherit from Cheetah templates
(which sounds useful, but I haven't used it yet).

> Or even, write a smallish webserver in python (using twisted maybe)
> whose only purpose is to serve pages and execute the embedded code...?

Well, you could always use the CGIHttpServer module that's in the
standard library for this. Cheetah templates can be tested outside the
sever environment, so you don't need a server to execute the embedded
code.

         <mike
-- 
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 mailing list