[ZPT] Added Python code blocks to ZPT

Ian Bicking ianb at colorstudy.com
Wed May 18 00:43:07 EDT 2005


Phillip Hutchings wrote:
> On 18/05/05, Ian Bicking <ianb at colorstudy.com> wrote:
> 
>>Well, ZPT is pretty slow moving these days, but there's a feature that
>>I'd be interested in.  It's inspired by Kid
>>(http://lesscode.org/projects/kid/), which is very similar to ZPT.  In
>>it, you can have Python code:
>>
>><?python
>>   ...
>>?>
> 
> This is precisely why TAL was created - to avoid having code blocks.
> Code blocks screw with things such as browsers when you use them
> outside of the preprocessor. With TAL I know how my template will look
> even when it has the TAL code in it. If I tweak the design I don't
> need to maintain a copy with TAL and without TAL, I just have one to
> work with.

Code blocks like I describe don't have any of those problems.  They 
prepare the data, they don't produce any output.  I guess if you 
produced chunks of HTML and then used "structure" to insert them then it 
would be a problem, but there's always ways to abuse things.

There exist places where display logic is complex.  This addresses that 
without mixing markup and complex logic, but does allow them to live 
close together, which I think is appropriate.  Complex logic in ZPT 
exists, right now; has anyone here not encountered this?  I think my 
<select> example is pretty normal; the alternative is either to push 
lots of display logic into the controller, create a third layer between 
controller and view, render large pieces of content outside of ZPT 
entirely, or figure out a way to better mix complex logic and ZPT.  I'm 
proposing the last of those.  The first is the current status quo. 
Rending code outside of ZPT is just the thing I mention above, and seems 
like exactly what you don't want.

A third layer is possible, and I'm open to that, but it's basically the 
same thing I'm talking about except split into two documents. 
Personally I think two tightly bound documents (and these would be 
*very* tightly bound) are just begging to be combined, which is why I 
prefer putting the block into ZPT.

-- 
Ian Bicking  /  ianb at colorstudy.com  / http://blog.ianbicking.org


More information about the ZPT mailing list