[Zope] Architectural decisions

Jim Penny jpenny at universal-fasteners.com
Tue May 25 11:40:29 EDT 2004


On Tue, 25 May 2004 16:28:14 +0100
"Ben Last" <ben at benlast.com> wrote:

> > From: Chris Withers [mailto:chris at simplistix.co.uk]
> > <tal:x define="testvar string:someobjectname;"
> >         replace="here/folder/?testvar"/>
> Wow, that's neat; saves a good many python: invocations.  Thanks,
> Chris.  As far as I can see that's not covered in any of the ZPT
> documentation or tutorials that I've pored through (and there seems to
> be nothing in the TAL Spec 1.4).  Is that new, or just obscure?
> 
> ben
I might mention that ZSQL results can be stored using tal:define, as
well.  Here, it is not so much about avoiding python: calls, as it is
about avoiding expensive calls, and/or extraneous methods.  Although, I
often find it increases readability, as well.

Example:

<body tal:define="sqlres container/my_sql_method">
  <table>
    <tr tal:repeat="rows sqlres">
      <td tal:content="rows/name1"></td>
      ...
    </tr>
  </table>
  <p><span tal:replace="python:len(sqlres)"> rows were found.</p>
</body>

Jim Penny



More information about the Zope mailing list