[mod_python] templating (was: supporting modular mod_python extensions vs. "folding" mod_psp)

Greg Stein gstein at lyra.org
Tue Jun 10 12:30:55 EST 2003

On Tue, Jun 10, 2003 at 11:53:33AM -0400, Hunter Matthews wrote:
> On Fri, 2003-06-06 at 17:52, Gregory (Grisha) Trubetskoy wrote:
> > The problem with Albatross for me is the same one with all the others - it
> > is yet another language to learn:
> > 
> > <al-for iter="name" expr="keys">
> >     <tr>
> >          <td><al-value expr="name.value()"></td>
> >          <td><al-value expr="environ[name.value()]"></td>
> >     <tr>
> > </al-for>
> > 
> > This is not Python. Nor is it HTML.
> I recently discovered PyMeld.py, which fixes this problem. There is also
> "simpleTAL"

Hunh. Just looked at this. It is a *very* neat approach (gonna have to keep
it in mind; the approach might be very useful in some contexts). But I
disagree that it "separates logic from HTML". As a specific counterexample,
take my edna mp3 streamer. For each song found in the "current" directory,
it extracts a whole bunch of ID3 tag information and makes that available to
the template. The default HTML template does not display that. But if you
switch over to the XML template, then it *is* present. (at one point, there
was a GUI that read the XML pages, so it wanted richer info)

With PyMeld, the logic must insert all the data somewhere in the page
(either as element contents or as an attribute). I don't see how you can
avoid putting _all_ the data into a PyMeld template. Thus, the logic is
intrinsically tied to the template.

IMO, there is never any true separation. Even with EZT, the logic must
provide "all" potential data, and let the template pull in what it needs.
(of course, there are things you can do to avoid pregenerating all data, but
semantically, the logic and template are still tied)

There will always be tying between the template and the logic because of the
data. If you say, "well, let the template define/generate the data it
needs", then you've just moved logic/processing into the template :-) Since
you can't get away from it, I built ezt with the view of "figure out the
relevant data, and then use *that* to render it." IOW, I took more of a
"render only" approach rather than some lofty, but unreachable, goal of
separation of logic.

> I prefer PyMeld really, except for the license.

EZT is under a BSD license, fwiw.


Greg Stein, http://www.lyra.org/

More information about the Mod_python mailing list