On Thursday, May 30, 2002, at 08:26 PM, Jan Smith wrote:
I have recently been looking at Zope Page Templates with a view to switching over to them in preparation for Zope 3. However as I understand it people are encouraged to use Python rather than DTML when using TAL.
You can include the output from DTML methods inside a ZPT document, just like any other method including PythonScripts. What you cannot do is embed DTML inside your ZPT document. What ZPT is actually encouraging is to separate the presentation and logic - there is an argument to be made that the python: TALES expressions should not be used (and indeed, I think Kevin mentioned at the last OzZope meeting that now his product is up and running, he is in the process of migrating these expressions out of the ZPT and into their own libraries). One thing of note - if you are using expressions in your DTML, you are already writing Python: <dtml-var "foo.absolute_url()"> This level of logic can be used in ZPT almost unchanged: <span tal:replace="python:foo.absolute_url()">URL</span> Or you may prefer the TALES syntax to make things nicer to read: <span tal:replace="here/foo/absolute_url">URL</span> I think the reason people are encouraged to use Python rather than DTML is how incredibly disgusting it is as a programming language, and a real pain to write and maintain. This is not always obvious to people who have come to DTML without much programming experience, people who have become used to this state of affairs, and people who don't even realize they are programming at all. It tends to be *very* obvious to ex-Perl programmers who moved to Python - the more vocal anti-DTML crowd seem to all have worked with Perl at some time :-)
TAL is not a replacement for DTML so what is the future for people who really like Zope and have DTML experience but not Python experience?
If you find that the DTML you used to write cannot be implemented in ZPT, you know enough about programming to go through the Python tutorial in a day or two and be much more productive. The time spent will more than pay itself off. *Don't* go and buy a Python book, as most of the stuff mentioned will be utterly useless to you unless you are writing Python products. And don't think you have to learn the Library Reference for the same reasons. I feel that Guido's tutorial is the quickest and best way of getting up to speed. Unfortunately DTML will not go away until a replacement template language is developed that addresses the needs that ZPT cannot (by design). ZPT is only useful for generating XML or HTML documents - if you want to include dynamic content in your CSS style sheets or are writing ZSQL methods you will still need it. Now that PythonScripts exist, it would be possible to redesign DTML to be much more usable but I don't believe there are any projects underway to do this. -- Stuart Bishop <zen@shangri-la.dropbear.id.au> http://shangri-la.dropbear.id.au/