[Zope3-Users] Is DTML Deprecated In Zope3?

Jim Washington jwashin at vt.edu
Tue Mar 20 23:29:44 EDT 2007


Mark, Jonathan (Integic) wrote:
> Phillip says in his book not to use DTML any more. However, I am finding that what is easy in DTML, producing an Atom 1.0 feed, for instance, is harder in ZPT. I get peculiar errors telling me that my XML boilerplate is not valid. DTML doesn't care. 
>
> I notice that in the Zope 3.3 ZMI you can create a DTML page. So is DTML going to be supported for the next few years?
>   
If you are publishing xml-ish content in zope 3, you might consider
using something like the techniques in zif.xtemplate.  zif.xtemplate
makes XHTML (with appendix c) documents, but you could easily do
something similar for Atom (or RSS) feeds.

zif.xtemplate uses lxml to create XHTML documents using the elementtree
API.  This means using python functions, classes and methods to get
around in your data, do looping, etc.  You can load and parse a template
from the file system as a starter piece.  Additional processing is
available with lxml's xpath and xslt support. 

I find this document-centric method a very nice thing to develop with. 
On the bad side, view code using this technique needs a z3 restart (or
z3reload) for changes, but on the good side, all error tracebacks are
standard python tracebacks.

zif.xtemplate is sort-of alpha for the moment.  I'm still evaluating
methods that need to be included, and those that are YAGNI.  We have not
done any benchmarks vs. ZPT, but it seems fast enough. It includes an
HTMLSanitizer for dealing with untrusted HTML.  In the default
pretty-print mode, zif.xtemplate puts out web pages with very pretty source.

zif.xtemplate is at http://zif.sourceforge.net .  We have not made any
releases yet, but to see/use the code, it's available in sourceforge's
svn repository.  I'm interested in feedback.

svn co
http://zif.svn.sourceforge.net/svnroot/zif/zif.xtemplate/trunk/src/zif/xtemplate

-Jim Washington


More information about the Zope3-users mailing list