RE: [Zope] small problem in external methods
-----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 )
Michel Pelletier wrote:
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__.
Unfortunately that isn't working.
BTW, this is a good question for zope-dev.
-Michel the overly subtle
Glad you raised that - to me external methods fit in the charter of both lists. ie discussion of the operation of Zope blends with discussion about the internal mechanisms of Zope. But I agree - perhaps we should try and keep anything with sample code on zope-dev, especially with the rise in non-coding traffic on the main list. Cheers, Martin
participants (2)
-
Martin Dougiamas -
Michel Pelletier