[Zope] not allowed to access a particular tuple

William Heymann kosh at aesaeion.com
Fri Oct 20 08:55:11 EDT 2006


This is an external method I wrote to make it easier to iterate over the 
records returned from searching the catalog. However if I have

yield record,item instead of yield item it says that I am not allowed to 
access a particular tuple during iteration. How can I make it so that the 
value that it yields is something that a python script object can iterate 
over? I have also tried doing yield tuple((record,item))  yield 
list(record,item)  and they give the same problem.


How I use the script is pretty much

for record, doc in catalogIter(context.Catalog(searchterms)):
    print record
    print doc

Of course what is inside is different from that but it will cause the same 
problem since the issue happens in the iteration not inside the for loop.

import zExceptions

def catalogIter(records):
    "iterate over a catalog safely"
    for record in records:
        try:
            item = record.getObject()
            if item is not None:
                yield item
        except (zExceptions.Unauthorized, zExceptions.NotFound, KeyError, 
AttributeError):
            pass


More information about the Zope mailing list