[Zope3-dev] Re: tal:define="..." considered harmful?
Jean-Marc Orliaguet
jmo at ita.chalmers.se
Sun Feb 12 05:53:52 EST 2006
kit BLAKE wrote:
>In 'normal' tal we often refactor our defines to improve efficiency.
>When something is called more than once in a template, we define it at
>the beginning, and then use it multiple times. This improves
>performance dramatically of course.
>kit
>
>
>--
>kit BLAKE
>Infrae · infrae.com · +31 10 243 7051
>Hoevestraat 10 · 3033GC · Rotterdam · The Netherlands
>_______________________________________________
>
>
In that case it's fine because the modifications of the data structure
are "local" inside the template. The data structure rendered by the view
does not get modified. Ideally you can always prepare the data structure
so that it already contains inside a dictionary the results you want to
display , it is always possible to do it.
however it is not OK when things start looking like:
tal:define="dummy python: context['item'] == sometool.getNewData()"
and the context or the request gets overridden.
Templates are not supposed to exchange data directly with one another. I
reckon that if "tal:define" is used, then the template should not have
write-access to the data model at all.
/JM
More information about the Zope3-dev
mailing list