[Zope-dev] Re: TALES idea: tuple unpacking

Shane Hathaway shane@zope.com
Fri, 25 Jul 2003 11:00:58 -0400


>> I only use 2 because it's there :-)  Thinking more about it, it
>> occurs to me that python expressions in TALES provide a huge hole
>> in the separation of presentation from logic. 

My view is that embedding logic in presentation isn't quite the right 
thing to avoid.  Consider how much "logic" goes into presenting HTML on 
the client side.  Yet browsers can't perform all of the logic, so some 
presentation logic has to exist on the server side.

Instead, two things are important: distinguishing presentation from the 
model and keeping syntax simple.  Python expressions in templates rarely 
violate the first principle because they are not part of the model. 
(Contrast this with PHP, where the model exists only in the 
presentation.)  Complex expressions violate the second principle because 
the syntax becomes unwieldy.

Jean Jordaan wrote:
> Perhaps it's worthwhile for this thread to have a look at 
> http://www.eby-sarna.com/pipermail/transwarp/2003-July/000606.html
> http://www.eby-sarna.com/pipermail/transwarp/2003-July/000607.html
> and following to see what Phillip Eby is cooking up.
> The templates he proposes have only two or three attributes, keeping 
> logic rigorously out of the template.

I like the idea.  It's a novel approach.  It may be oversimplifying, 
though, and the danger of oversimplifying is that some other part 
acquires extra complexity to compensate.  For example, if we were to ban 
Python expressions outright in ZPT, it would become necessary to 
compensate by writing at least one Python script per template that used 
to have expressions.  In a product I'm maintaining for a customer, that 
would be a very big burden.

Shane