I haven't tried it in ZPT, but it *should* work.
From your code: <table tal:define="list_ppl python:container.show_list().dictionaries()"> <tr tal:repeat="res list_ppl"> <td tal:repeat="column python:res.keys()" tal:content="python: res[column]">/td> </tr> </table>
SQL methods apparently have a method dictionaries() which returns the result rows as dictionaries. -jim -----Original Message----- From: Samuele Giovanni Tonon [mailto:samu@sferacarta.com] Sent: Tuesday, April 20, 2004 5:38 AM To: zope@zope.org Subject: [Zope] ZPT and SQL hi, i would like to access to results from a Query without knowing before names returned from the SQL and all with ZPT i think it could be clear with this example: suppose you have ZPT with this inside: <table tal:define="list_ppl container/show_list"> <tr tal:repeat="res list_ppl"> <td tal:content="res/name">Name</td> <td tal:content="res/lastname">Lastname</td> </tr> </table> show_list is this SQL method " SELECT * from ppl" this work, but i would like to make that table dynamic, so that i haven't to call esplicit the name of the column "name" and "lastname". Also it means that the number of td will change (so i should nest some tal:repeat inside ). i saw it's possible to ref to data inside res with index ( (res[0], res[1]) and i tried something like this but it's not working. Any tips ? <table tal:define="list_ppl container/show_list"> <tr tal:repeat="res list_ppl"> <span tal:define="num python:range(len(res))"> <span tal:repeat="vars python:res[num]"> <td tal:content="vars">vars</td> </span> </span> </tr> </table> i tried to search on google for some example of this kind but got no clue TIA Samuele _______________________________________________ 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 )
participants (1)
-
Jim Kutter