[Zope] Translating DTML into Python Script

Andreas Pauley andreasp@qbcon.com
Mon, 11 Jun 2001 12:40:43 +0200


Hi all,
I would like to translate the following piece of DTML code into Python
Script:

<dtml-in "objectValues('Folder')">
  <a href="<dtml-var id>"><dtml-var title_or_id></a><br>
</dtml-in>

What I would like to achieve is to loop through the objects returned by
my Python Script:
<dtml-in MyPythonScript>
  <a href="<dtml-var id>"><dtml-var title_or_id></a><br>
</dtml-in>

This is what I have tried so far on the Python side:
objlist=[]

for obj in context.objectValues('Folder'):
	objlist.append(obj)
return objlist

But when I try to loop through these results I get the following error:

Error Type: AttributeError
Error Value: __getitem__

I have also tried appending obj.id to the objlist, but that didn't solve
the problem either.

Do I have to return objects in a certain format/type before I can loop
through it with DTML?

The reason I would like to return my objects with Python is so that I
can implement some logic as to what objects are returned, eg. only
return DTML Documents that have id's containing certain characters etc.

Thanks a lot,
Andreas.