[Zope] How to Learn ZPT or DTML??

Paul Winkler pw_lists@slinkp.com
Thu, 30 May 2002 15:10:02 -0400


On Thu, May 30, 2002 at 09:44:17AM -0700, Frank Peavy wrote:
> Being new to Zope, I would like to minimize my learning curve to some 
> extent.
> I guess I am a little confused between the uses of TAL, ZPT and Python.
> 
> Where should one start to learn TAL? or ZPT?

TAL is part of the whole system referred to as ZPT, which also
uses TALES and METAL. For now, it'll be easier for you to just
think of it as ZPT.  You may have been confusing TAL with DTML
which is an older templating system.

Following is my quick summary comparing the uses of DTML, ZPT,
and Python. I tried to keep it neutral with respect to DTML vs. ZPT
which is kind of a hot topic these days.


DTML (Dynamic Template Markup Language): 
the established Zope template language. Used for creating
dynamically rendered HTML pages. To learn DTML, try the
tutorial that comes with Zope.

Pro:  

 * LOTS of example code and docs
 
 * stable, probably pretty thoroughly debugged by now
 
 * renders pretty quick

 * You can do a lot with just DTML.

Con:

  * You can do a lot with just DTML - including get yourself
    in big trouble by making big complex DTML pages that nobody
    (including you) can understand.

  * Doesn't play nicely with WYSIWYG editors (dreamweaver et al).

  * Takes some getting used to (e.g. <dtml-var foo> and
    <dtml-var "foo()"> are often the same thing, and newbies are
    often confused about the difference. Things in quotes are
    implicitly python expressions). 


ZPT (Zope Page Templates):  
a newer Zope template language. Also used for creating
dynamically rendered HTML pages. To learn ZPT, look at the
online version of the Zope Book:
http://www.zope.org/Documentation/ZopeBook/ZPT.stx

Pro:  
  * valid as XML, so works well with XML tools including
    WYSIWYG editors.

  * More explicit: e.g. to call a bit of python code "inline", 
    you use the python: qualifier instead of just quotes. 

  * Allows for "dummy" content so the raw template can be viewed in a
    browser and show you something representative.

  * Doesn't allow you to do very complex logic, which encourages
    you to put logic where it belongs - in python.

Con:  
  * renders slower than DTML at the moment. This will probably
    improve.  

  * More verbose so it takes longer to type a page.

  * Takes some getting used to (e.g. doing all the work
    in attribute tags may seem odd because you've probably
    never seen another system that works that way).


Python:
A programming language. The language used to implement Zope
and to create Products and little bits of logic ("Python Scripts"
and "External Methods"). It's commonly agreed by Zope developers
that *any* logic that isn't totally trivial should be done 
in python, whether that's in a Python Script, an External Method,
or a Product. To learn Python, there are many options; I suggest
"How to Think like a Computer Scientist", a very newbie-friendly
document at http://www.ibiblio.org/obp/thinkCSpy/

Pro:
  * Probably one of the easiest programming languages to learn.

  * Extremely dynamic and flexible.

  * You can make Zope do *anything* if you learn python
    and start digging around in the Zope API.

Con:

  * There is nothing bad about Python. ;-)


As for learning them...
I'd suggest keeping a bookmark to

-- 

Paul Winkler
home:  http://www.slinkp.com
"Muppet Labs, where the future is made - today!"