On Friday 06 February 2004 09:37, Sven Jacobs wrote:
Dear newsgroup,
I want to iterate over a list returned by a Python script using the <dtml-in> tag of Zope. The script looks like this:
# Script BEGIN missing = []
for curprop in context.sqlGetObjectProperties(objid=curobjid):
found = 0
for prop in context.sqlGetObjectTypeProperties(objtypid=curobjtypid): if (curprop.propid == prop.propid): found = 1
if (found == 0): missing.append(prop.propid)
return missing # Script EOF
The test DTML document looks like this
<dtml-in expr="pyGetMissingObjectProperties(curobjid=objid,curobjtypid=objtypid)"> <dtml-var sequence-index><br> </dtml-in>
and works fine, I see several sequence indexes. But how do I actually access the values from the list? <dtml-var missing> within the <dtml-in> block does not work :(
Of course : "missing" is not a property of each item in the list : it's the list itself, which is returned by the Python script. To get the value of the item, just use <dtml-var sequence-item> (or <dtml-var toto> if each item in the list has a property called "toto"). Thierry