[Zope] Returning lists from python back to dtml
Thomas B. Passin
tpassin@mitretek.org
Thu, 25 Jul 2002 10:48:10 -0400
[Isokangas, Erik HTC/DE/FRA]
> However, I wish to pass a table of results with 'column names' (in
layman's
> terms), such that I can read the returned results something like...
> <dtml-in "getResults()">
> <dtml-var Column1> <dtml-var Column2> <dtml-var Column3>
> </dtml-in>
>
> So, how do I pass named results from python script to dtml?
>
If you have a set of rows from the table, make the return value to be a list
of dictionaries. Then use the keyword "mapping" with dtml-in -
getResults() returns, say,
[{"Column1":1,"Column2":2}, {"Column1":3,"Column2":4}]
<dtml-in "getResults()" mapping>
<dtml-var "_['sequence-item']['Column1']">
</dtml-in>
Cheers,
Tom P