small problem in external methods
Another small Zope/Python problem I just can't seem to nail, no matter what docs I read. In one of my external methods, I have the name of a subfolder in a string variable. How can I reference properties of this subfolder? ie this seems like it should work, but doesn't: def example(self): foldername = 'fred' subfolders = self.objectItems(['Folder']) return subfolders[foldername].title Ideas? -- ### Martin Dougiamas -- Internet Agent "...The Eighties, ### Centre for Educational Advancement the Nineties, ### http://cea.curtin.edu/staff/martin the Naughties."
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Martin Dougiamas Sent: dinsdag 25 mei 1999 9:00 To: zope@zope.org Subject: [Zope] small problem in external methods
Another small Zope/Python problem I just can't seem to nail, no matter what docs I read.
In one of my external methods, I have the name of a subfolder in a string variable. How can I reference properties of this subfolder?
ie this seems like it should work, but doesn't:
def example(self):
foldername = 'fred' subfolders = self.objectItems(['Folder']) return subfolders[foldername].title
Ideas?
Um, shouldn't that be self.objectValues ? Rik
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
participants (2)
-
Martin Dougiamas -
Rik Hoekstra