[Zope] Using tal and no dmtl.

Dmitry Dembinsky dmitry@deluxoft.com
Fri, 30 May 2003 21:06:07 +0200


> On Fri, 30 May 2003, Paul Winkler wrote:
> 
> > On Fri, May 30, 2003 at 09:34:50AM -0400, John Kipling Lewis wrote:
> > > On Fri, 30 May 2003, Dmitry Dembinsky wrote:
> > >
> > > > We use tal:define for this purpose:
> > > >
> > > >   <body tal:define="dummy python:foo(); <other assignments>" ...
> > > >
> > > > Usually this way we run some page setup code which we 
> put inside 
> > > > <body> or even top-level <html> tag.
> > >
> > > We have done this as well.  It just seemed an obvious hole in the 
> > > tal system.  There should be a way to execute arbitrary 
> code in tal. 
> > > Something like:
> > >
> > > <body tal:run="python:foo()">
> >
> > tal:define works perfectly well for this.
> > I don't think we need a new tal statement just for the 
> special case of 
> > not caring about the return value.
> 
> If define allow you to not "define" a variable then I would 
> agree, but it's confusing for people looking at the code to 
> define a variable and then never use it.  For example:
> 
> <body tal:define="foo python:foo()">
> 
> If foo() doesn't return anything, you've just defined a 
> variable foo that doesn't do anything which will confuse 
> anyone who is new to the code.  I shouldn't have to define a 
> variable just to run foo().
> 
> John -
> 
John, I think you exaggarate regarding this "problem".
It is simply resolved by naming unneeded return value "dummy" or
"unused".
This way it wouldn't confuse anyone looking at the code. 

IMHO, keeping tal simple is more important that providing nice-to-have
features for easily avoidable situations.
Just compare an effort that'd be required to implement a dedicated TAL
attribute for running scripts with using ready and working solution you
have in hand.

Dmitry.