Python embedded like PHP

Paul Boddie paul at boddie.net
Fri Mar 29 09:55:54 EST 2002


Jon Ribbens <jon+usenet at unequivocal.co.uk> wrote in message news:<slrnaa3bi8.lam.jon+usenet at snowy.squish.net>...
>

[HTML in Python code]

> 
> ... and 'jonpy' avoids the issue entirely by neither embedding Python
> in HTML or HTML in Python. Its templating system embeds *no code of
> any sort* in the HTML and this turns out to be completely super ;-).
> See http://jonpy.sourceforge.net/wt-examples.html#templatecode for
> examples.

It's actually quite reminiscent of the earliest versions of DTML, in
fact, where comments are used to mark the structure of the "model" as
opposed to the special tags which were introduced in DTML later on.

> This is especially useful when you have different people generating
> the HTML and the code (as it almost always the case). The designer is
> much less likely to mangle the 'significant' parts of the HTML files,
> and even if they do, it's a matter of seconds to fix.

Zope Page Templates takes the other "under the radar" approach, of
course, using special attributes which HTML editors usually don't want
to touch. I suppose only testing of what different editors do with
attributes and comments can determine whether special attributes or
comments are best to avoid "destructive editing" when HTML files are
redesigned.

I agree with Jon that the ability to divide work into separate
activities of page design and application development is very
important, especially in situations where designs may change rapidly
over time. Indeed, any help in partitioning workloads is essential for
many kinds of applications; otherwise the software developers end up
not only doing their own work, but also intensively managing the
changes made by designers, potentially resulting in "workflow
bottlenecks" around developers while designers wait impatiently for
the application to take on its new look.

> Additionally, when the customer says "actually, we don't like the style of
> the site, we want it changed" and you get sent a whole bunch of new code-less
> HTML files, with a PHP-style code-in-HTML you pretty much have to
> reimplement the entire site from scratch, whereas with this system you
> just add back in the section markers and the code (which was in
> separate files anyway) does not usually need to be changed at all.

I think that while some applications probably do need a lot of control
over their own presentation, demanding a programmatic approach to
output generation, in many applications once the problem of generating
output in a maintainable way has been resolved, the most common
subsequent problem is handling the input from users and finding a way
to reduce the maintenance on this activity as well. In the Python
community, there is obviously an intense interest in templating, but I
haven't seen more than a handful of validation packages, and I can
imagine that few of them actually integrate satisfactorily with
template packages.

Paul



More information about the Python-list mailing list