[Zope] Returning lists from python back to dtml

Klaus Herrmann klaus.herrmann@goelz.com
25 Jul 2002 17:00:11 +0300


> 
> 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?

from python, you pass an array of dictionaries:

#results()
return [{'colum1': 'value1', 'column2': 'value2'}, {'colum1': 'value12',
'column2': 'value22'}, ...]

in dtml you do:
<dtml-in "results()" mapping>
    <dtml-var column1>...<dtml-var column2>....
</dtml-in>

have fun,
	Klaus

 
-- 
Goelz & Schwarz GmbH
Waltherstrasse 29, 80337 Muenchen, Germany
phone: + 49 - (0)89 / 54 46 70 - 0
fax: +49 - (0)89 / 54 46 70 - 10
e-mail: klaus.herrmann@goelz.com
web: http://www.goelz.com