[ZPT] Re: [Zope-dev] Re: [Vote] PEP308 voting began

Joachim Werner joe@iuveno.de
Fri, 07 Mar 2003 07:33:44 +0100


>> (Tested with
>> <div tal:replace="if:options/x then:string:yes else:string:no">)
> 
> 
> There are an awful lot of colons in there :-)

Indeed ...

> Here's an off-the-wall idea:
> 
>   <div tal:replace="talif"
>        tal:if="options/x"
>        tal:true="string:yes"
>        tal:false="string:no"
>        >
> 
> This looks better as a tal:tag
> 
>   <tal:block
>       replace="talif"
>       if="options/x"
>       true="string:yes"
>       false="string:no"
>       >
> 
> Or, if you only use this kind of thing with tal:replace, tal:content and 
> tal:define.
> 
>   <tal:block
>       defineif="foo options/x"
>       true="string:yes"
>       false="string:no"
>       >
> 
> Of course, none of this helps for tal:attributes.

If I understood the intentions of ZPT right one of the ideas was to get 
rid of too much application logic in the template. But currently ZPT 
seems to be extended to become very similiar in functionality to DTML. 
I'd prefer to see an approach where Python is used wherever it makes 
sense and ZPT is kept as simple and stupid as possible. If a user has to 
learn new syntax it is, IMHO, better to let him learn the Python syntax, 
so he will be able to more easily migrate to using more Python later. 
More advanced ZPT that uses a lot of Python, like the one used in some 
Plone skins, really becomes very ugly and hard to read, even compared to 
DTML. My first impression from Zope 3 was that it becomes better there 
because of the heavy usage of views that specify helper methods that 
then are used from the ZPT.

The most trivial approach to this is "Python Server Pages" (which has 
been implemented a couple of times), i.e. being able to write inline 
Python code in HTML/XML, but this doesn't have the elegance of ZPT 
(staying compatible with WYSIWYG HTML editors etc.).

I don't know how to actually do this right now, but from a usability 
point of view it seems to me that the best solution would be similar to 
what you get in Windows RAD IDEs, where I can select a widget and then 
write code for it in a pop-up box. That would mean that in the ZPT there 
just is a very simple directive, like a tal:replace or tal:content, but 
I can expand this with a mouse click to get to a Script (Python) where I 
can write the code that will create the actual content.

Joachim