[Zope] Loop over the different levels of PARENTS

Nico de Boer nico@nfg.nl
11 Jun 2002 10:12:40 +0200


Hi all,

I want to loop over the different levels of PARENTS to get the id of
the ZCatalog. The id of the ZCatalog can be dynamic this way.

I've written some code to do this:

    def getCatalogid(self):
        """gets the id of the ZCatalog used for the News searchin"""
        level = len(self.REQUEST['PARENTS'])
        for item in self.REQUEST['PARENTS'][level].objectValues('ZCatalog'):
            catalogid = item.id
            level = level-1
        return catalogid

But I get the following error:

File /var/lib/zope/Products/News/News.py, line 876, in getCatalogid
    (Object: newstest)
IndexError: list index out of range

Line 876 is the line with the 'for item in ....' expression.

Does anybody know how to do this?

Greetz Nico