I wrote a Java implementation of Zope Page Templates (ZPT)

Stefano Masini stefano at stefanomasini.com
Mon Feb 10 05:38:58 EST 2003


Since I could not find any implementation online, I few days ago I
decided to implement Zope Page Templates in Java myself, following the
TAL and TALES specifications.
No rocket science, I'm sure. I just wanted to share this code with
anybody who could be interested.

I'll eventually set up a web page, but for now, I'll just send you the
code by email, if you want it.
If you want to contact me, please write to stefano at stefanomasini
dot com (you can figure out the real address, hopefully spammers
won't...). Please do not reply to the newsgroup, since I don't read it
frequently.

The implementation is not 100% complete with respect to the specs, but
I tried to stay compliant. So far TAL is complete, TALES has path:,
not: and string:. Mhmm... I just realized I forgot exists:... that
must be because it's not in the specs. I guess I'm gonna implement it
right now then, it'll just take a few minutes at this point. METAL is
not implemented at all, and I'm not planning on supporting any java:
type in TALES, for now.
Data is passed to the template using HashMap for path expressions,
Vector for iteration loops. Any other object type is stringified using
toString().
The template is parsed at construction time, so that at evaluation
time only the parse tree needs to be traversed and executed. This way
the rendering of a finished html page should be quite fast, if all the
necessary templates are initialized in the servlets at startup.

The low level html parsing is done through a free library that I found
from quiotix.com (thanks!). It's the first chunk of code that I found.
I initially tried with a more formal approach, involving xhtml, but I
soon realized that a full xml validating parser was way too
complicated for my simple purpose.

Last, but not least, my code is under GPL, so it provides NO WARRANTY.
Use at your own risk.

I hope somebody will find it useful.
Stefano




More information about the Python-list mailing list