(For gurus) Embed functions in webpages like in PHP?

has has.temp2 at virgin.net
Fri Apr 16 18:06:44 EDT 2004


Robert Ferber <rob at nospam.net> wrote in message news:<5eq4l1-9vm.ln1 at pilz.hasos.com>...

> As far as I've seen, there is no way to embed Python-code in a webpage with
> "<? ?>" or anything equivalent and I don't see any other way to solve this
> problem.

If you're open to alternatives, there's also several simplified-DOM
templating engines:

http://www.entrian.com/PyMeld/

http://www.divmod.org/Home/Projects/Nevow/

http://freespace.virgin.net/hamish.sanderson/htmltemplate.html

I think Nevow's maybe still a work in progress, but the other two have
been around awhile. (I recommend HTMLTemplate myself, though may be
biased as it's one of mine.:)

These systems are much simpler and more flexible than traditional
'code-in-markup' systems, compiling an HTML template into a simple
object model that can be manipulated directly from Python code. Bit
different to what you're used to, but you really should give 'em a
look. Simple APIs, low cruft/bloat, and total separation between
presentation logic (in Python) and HTML markup. Can be used on their
own, or in conjunction with a web framework like Quixote.

Not sure of the others, but HTMLTemplate certainly allows you template
both full pages and HTML chunks so you can easily compose a page from
multiple parts, so implementing selective caching and reuse of
semi-static page areas should be straightforward.



More information about the Python-list mailing list