[ANN] HTMLTemplate 1.0.0

David Bolen db3l at fitlinxx.com
Mon Jun 7 23:09:55 CEST 2004


grahamd at dscpl.com.au (Graham Dumpleton) writes:

> Now as to other template systems that are event driven system friendly,
> the only one I know of for Python is Nevow, but that is bound up with
> Twisted and thus couldn't be used with any other system. For my mind,
> from the little I have looked at the Nevow examples, I am also not keen
> on its magic system for callbacks dependent on naming. This sorts of
> binds it quite tightly to a particular way of building your classes which I
> would rather avoid.

Note that even if the template system isn't directly event driven
friendly, it can generally be used just fine with Twisted since you
can acquire your data prior to rendering the template.  For example,
we are currently using ZPT with Twisted.  We pre-compile the templates
for pages when the web objects (which are basic twisted.web Resource
objects) are built to establish the web site.  Then, when asked to
render a page, we can take our time working up the necessary context
data (since the Twisted Resource object can return a pending indicator
and the object can then use the normal Twisted deferred processing to
complete the rendering).  It's only once the data is fully realized
that we ask ZPT to use the compiled template to construct the HTML.
That operation is synchronous but there's no business logic running at
that point, and no timing dependency between the original request and
the final rendering.

HTMLTemplate could be inserted into the same mix as long as we held
off asking HTMLTemplate to render the DOM into HTML until we had all
the necessary data acquired to answer the various callbacks
immediately.  That's probably the biggest advantage of Woven/Nevow in
a Twisted context with respect to a more MVC model - they integrate
cleanly into Twisted's event driven fabric with deferreds even during
individual element callbacks so you don't have to prepare all the data
in advance but can be driven from the template rendering process.

-- David



More information about the Python-list mailing list