[Zope-DB] Learning Page Templates

Charlie Clark charlie@begeistert.org
Thu, 12 Jun 2003 19:32:09 +0200

On 2003-06-12 at 18:31:14 [+0200], Lindstrom Greg - glinds wrote:
> This is off db, but *you* brought it up.  I worked my way through the=20
> "Zope Bible" and didn't run across Page Templates until the very end.=20=20
> Could you give me some insight on the following (and though  some of this=20
> may sound like flame bait, it is not my intention at all; all these=20
> concerns are genuine)

This is unlikely to develop into a flame war. For what it's worth I started=20
with DTML myself and realised pretty quickly: it's good for quick and easy=20
stuff; it's awful for any kind of logic above a very simple loop or=20
> 1.  I have read about the "whys" of Page Templates in the Zope Bible.  Is
> this just a style question?  And would I find as many people advocating=20
> DTML as Templates if I looked?  I think of the Perl versus Python=20
> "debate" (usually little more than flaming) where there are good people=20
> on both sides insisting that their way is the only true way to code when=20
> the truth is that both Perl and Python have pros and cons, and both can=20
> pretty much be used in most cases.  Is this the case for DTML and Page=20
> Templates, or are there objective reasons to use Templates?

Why do I prefer ZPT over DTML:
editing with an editor such as Dreamweaver via ExternalEditor is much=20
easier because ZPT must be xHTML compatible and is less likely to be=20
destroyed by an editor. Yes, I do like to use an external editor rather=20
doing everything in a text area. This means incidentally that you know your=20
code will work in a browser which isn't necessarily the case with DTML;

putting logic in tag-attributes is such a good idea that it can be found in=20
Java tag-libs and in .NET or whatever it's called at the moment;

ZPT has less powerful constructions for data or presentation manipulation=20
encouraging the use of PythonScripts or ExternalMethods. I've found this to=20
be very helpful when looping through certain database query results: it=20
comes to me more naturally in ZPT than in DTML where I might try and do a=20
lot directly in DTML;

use of Python statements is also explicit in ZPT rather than implicit as in=20
DTML. This is Python Zen. Namespaces are also much better managed: no "_."=20
super weird namespace. I'm still not happy with different types of syntax=20
for TAL and Python ie. here/something and here.something or the need to=20
switch to a Python statement in order to pass parameters but I think these=20
are minor when compared to some of the real headaches I've had with DTML;

reusability of parts/code is positively encouraged through Macros and=20
METAL. Yes, they take some time to learn and grasp (I'm still doing this)=20
but they leave much more maintainable code;

DTML will become obsolete at some point so you will have to rewrite at some=20
point. There is just too much opinion against it and CMF/Plone - major=20
drivers for the adoption of Zope for content managemeant - don't use it;

> 2.  How do I go about learning templates?  My Zope Bible is not up to=20
> date.
> As I recall, when I tried to go through the material in the book, the=20
> interfaces were different than those on my computer.  Should I read up on=20
> XHTML first?  Are there white papers, or up to date documentation? Is=20
> there something equivalent to the Elvis tutorial for templates?

No, you don't need to worry about xHTML, just be comforted by the fact that=20
you're working to a standard. I started by converting some fairly hacky=20
DTML pages to ZPT and being fairly rigorous in this. All I had for this=20
were the two chapters in the online help which I printed out and studied=20
carefully. They are two of the best things in the online help, which while=20
it has come a long way is still fairly shoddy in places. I do not write=20
DTML anymore except in ZSQL-methods where I like <dtml-sqlvar> doing some=20
sanity checking for me and find <dtml-if> just about bearable.
> Thanks for your time and understanding.  I *love* working with Zope and=20
> look forward to your reply.

No problems, hope the answer is what you were looking for and helpful to=20
anyone else. I like Zope, too but it's important to point out it's=20
weaknesses now over to Marc-Andr=E9 and Dieter about the problems with=20
Zope-DA's! :-)