Templating engine?

Daniel Ellison daniel at syrinx.net
Mon Jun 21 06:49:47 EDT 2004


has wrote:
> PyMeld, Nevow.renderer and HTMLTemplate all provide complete
> separation of business and presentation logic from HTML markup. These
> support desktop application-style MVC, where GUI widget classes (View)
> are separated from the code that controls them (Controller).*
> 
> Also, because they're designed specifically for templating, they
> should also be a lot simpler and easier to use than generic DOM
> systems such as ElementTree.
> 

Who said ElementTree was a generic DOM system? In fact it's not. It /is/
hierarchical, but doesn't use any DOM API I know of. From the
ElementTree web site:

<quote>
The Element type is a simple but flexible container object, designed to
store hierarchical data structures, such as simplified XML infosets, in
memory. The element type can be described as a cross between a Python
list and a Python dictionary.
</quote>

ElementTree has *very* primitive support for XPath, which we easily
extended to support lookup on ID. With this in place (literally no more
than 20 LOC) ElementTree is a usable system which allows us to
achieve the complete separation we were looking for.

Admittedly, the just-in-time lookup on IDs is less than ideal. Better 
would be a system which cached the elements containing IDs in a 
dictionary on parsing the document. I believe this was the reason Mr. 
Hansen and I decided to write our own system back about a year ago. Of 
course, that was in another life...

Daniel Ellison



More information about the Python-list mailing list