[Zope3-dev] <script> - the anti-pattern

Phillip J. Eby pje at telecommunity.com
Wed Sep 10 09:37:30 EDT 2003


At 09:55 AM 9/10/03 +0100, Chris Withers wrote:
>Tres Seaver wrote:
>
>>On Sun, 2003-09-07 at 10:54, Stephan Richter wrote:
>>
>>>On Friday 05 September 2003 17:47, Jeffrey P Shell wrote:
>>>
>>>>I'm very very afraid.
>>>
>>>As Jim said, 'Don't be afraid!' :-) The things you are afraid about will 
>>>never cross your way.
>>Unfortunately, both Jeffrey and I have had to come in behind  "quick and
>>dirty" scripters and clean up the nightmares they leave behind, on a
>>number of occasions.  The fact that their mess "works" makes imposing
>>discipline afterwards much harder (the "ship the prototype"
>>anti-pattern).
>
>Just so you know, this is why I'm so vocal about this.
>
>I've come into contact with several companies who've totally rejected Zope 
>based on trial projects which other companies have implemented for them 
>that have resulted in this anti-pattern....
>
>Chris

For what it's worth, there exists a templating approach that makes it 
*impossible* to put code into templates, but still makes it possible to 
create arbitrary dynamic content in an extensible way.  There are three 
different Python systems that use this approach: PSO, twisted.web.woven, 
and peak.web.templates.  Essentially, in all three approaches, a special 
attribute of an XML/XHTML tag specifies a factory for a Python object that 
will be responsible for rendering the contents of that tag.

Thus, the visual designer is limited to expressing only concepts that are 
made available by the author of the Python objects.  Of course, in a 
Zope-like app server, it should be possible to download and install such 
"controls" or "widgets" (peak.web calls them "DOMlets") from whoever makes one.

If you want to enforce a strict separation between markup and code, that 
still allows for arbitrary dynamic complexity, this pattern is the way to 
go.  The downside to the pattern is that there is *absolutely* no 
"scripting", in a programming language sense.  If you want to create 
something entirely new, you need to write Python code, unless somebody else 
has written something for you that works like you need it to.  In Twisted 
and in PEAK, the templating approach includes a way to mark content as 
"patterns" or "parameters", though, so changing visual appearance for a 
particular widget is well within the bounds of scriptability.  For example, 
a simple "list with selection" DOMlet could equally well render tabs, 
navigation menus, drop-down fields, and anything else that involves a list 
with a selected item that's somehow different from the un-selected items.

Of course, neither PSO, Woven, nor peak.web.templates currently are usable 
with Zope 3, but if somebody cared about that, they could certainly change 
the situation, or write their own variant of the idea.  The core engine for 
peak.web.templates took only an afternoon for me to prototype, so it's not 
rocket science.




More information about the Zope3-dev mailing list