[ZPT] Using ZSQL from ZPT

Brian Watson doc@pcola.gulf.net
Thu, 21 Mar 2002 10:38:15 -0600


Hello Everyone,

I'm trying to iterate over the results of a ZSQL Method in ZPT.  I just need
a table row displaying each column in the db table for each table row
returned from the method.  I'm trying it like this:

  <tr tal:repeat="results
python:container.DataReader.getResults(usr_name=container.portal_membership.
getAuthenticatedMember().getUserName())">>
    <td tal:content="python:results[][]">content</td>
    <td tal:content="python:results[][]">content</td>
  </tr>

and I've also tried the results/... way, but still no luck (the item/x way
just doesn't work and the [] way results in an unscriptable object error).
How do I use the results or is there a preferred way to do this?  I've seen
two solutions: call a script that fixes up the ZSQL results before returning
them to ZPT and call a script first that fixes the results and then calls
the ZPT passing the results in a built-in ZPT variable.  It just seems like
ZSQL is so ingrained in Zope that there should be a simple way to use them
in ZPT.

Thanks in advance,
Brian W.