[Zope] Getting the id of a DTML Document/Method in Python

Andreas Pauley andreasp@qbcon.com
Wed, 13 Jun 2001 13:18:47 +0200


Hi all,

I'm trying to write an external method that will loop through all my
DTML Documents, and return only objects that match a certain criteria
(based on its id).

Instead of the id, my External Method returns:
[<Python Method object at 83df298>, <Python Method object at 86e9ba8>]

whith the following sample code:
---
def LinkGenerator(self):

    objlist=[]

    for obj in self.objectValues('DTML Document'):
        objlist.append(obj.id)

    return objlist
---

If I change the self.objectValues('DTML Document')
into self.objectValues('Folder'), obj.id returns the correct id:
['folder1', 'folder2', 'folder3']

I've tested a few objectValues, and as far as I can tell it is only DTML
Documents and DTML Methods that does not return the id correctly.

How can I get to the id of a DTML Document/Method when looping through
the objectValues() ?

Ultimately I want to do this:
def LinkGenerator(self):
    import re
    objlist=[]

    for obj in self.objectValues('DTML Document'):
        res=re.search('^link', obj.id)
        if res:
            objlist.append(obj)

    return objlist

And then use DTML to loop through the resulting objectlist:
<dtml-in LinkGenerator>
  <a href="<dtml-var id>"><dtml-var title_or_id></a><br>
</dtml-in>

Thanks a lot,
Andreas.