[Zope] small problem in external methods

Martin Dougiamas martin@complex.curtin.edu.au
Tue, 25 May 1999 19:54:11 +0800 (WST)


I wrote:

> this seems like it should work, but doesn't:
> 
> def example(self):
>     foldername = 'fred'
>     subfolders = self.objectItems(['Folder'])
>     return subfolders[foldername].title 

Thanks to Rik Hoekstra for pointing out tuples don't behave like
dictionaries, and to Dr. Ross Lazarus for a better way:

def example(self):
    foldername = 'fred'
    if foldername in self.objectIds():
        return getattr(self, foldername).title

The Zope list comes through again!

Cheers!
Martin