[Zope] small problem in external methods

Michel Pelletier michel@digicool.com
Tue, 25 May 1999 09:39:17 -0400


> -----Original Message-----
> From: Martin Dougiamas [mailto:martin@complex.curtin.edu.au]
> Sent: Tuesday, May 25, 1999 7:54 AM
> To: martin@complex.curtin.edu.au
> Cc: zope@zope.org
> Subject: Re: [Zope] small problem in external methods
> 
> 
> 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


I believe 'return self[foldername].title' will also work.  Folder
objects support __getitem__.

BTW, this is a good question for zope-dev.

-Michel the overly subtle

> 
> The Zope list comes through again!
> 
> Cheers!
> Martin
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://www.zope.org/mailman/listinfo/zope
> 
> (For developer-specific issues, use the companion list,
> zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
>