[Zope] Using tal and no dmtl.

Dmitry Dembinsky dmitry@deluxoft.com
Thu, 12 Jun 2003 03:44:46 +0200


Tino, probably an approach you offer better serves the
logic/presentation separation, though it is not flawless as well.
Of course, defining a bunch of variables in a page template using
complicated expressions is an obvious misusing of ZPT.

However, IMO, something like

<span tal:define="item python:here/findItem('123')"
tal:content="string:${item/getId}: ${item/title}">Id: Title</span>

is more simple than using parametrized template and having "item"
defined elsewhere.

Not to mention that if I see smth like tal:content="options/values" in
someone's code 
I have no clue where the "values" comes from and how it is calculated 
(unless the code is properly commented :)

I think how you write the code is mostly a matter of taste.
Usually, one will use his/her favorite method, not the one that is
considered "best practice"
by someone else - we're human beings, not machines :)
e.g. there are people that don't understand what OOP is for, but still
write great programs :)

And definetly, there is no place here for the holy war, as John assumes.
Call it an "intellectual duel" if you wish :)

Best regards,
Dmitry

> Hi,
> 
> 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()">
> > 
> > John -
> 
> I have to disagree whith this. Even tal:define is somewhat 
> ugly. The design goal has to be to remove as much application 
> code as possible from template. So always set up your data 
> outside of the template.
> 
> A handy way is to have a simply python script "dispatcher" 
> method which calculates all values and stuff and then returns 
> the actual template like this:
> 
> -- python script --
> contect.callSomething()
> val=context.calculateSomething()
> 
> return context.Template(values=val)
> -- /python script--
> 
> in this example you can access values
> thru options/values in TAL.
> This is clean and handy.
> You even can return different templates according to
> a condition and set header information and so on.
> 
> HTH
> Tino Wildenhain
> 
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org 
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross 
> posts or HTML encoding!  **
> (Related lists - 
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
>