I'm trying to emulate some DTML methods with python code in my (python) product. Let's say I have two Python classes, one named Foo, the other Bar. Something like this: class Foo(Folder.Folder, Persistent, Implicit): meta_type = "Foo" def magic(self, client=None): "magic method!" if client == None: client = self return client.magic_word class Bar(Folder.Folder, Persistent, Implicit): meta_type = "Bar" def __init__(self, id): self.id = id self.magic_word = 'Alacazam!" Now I create a structure like this in Zope: / foo (instance of the Foo class) bar (instance of the Bar class) Now if I goto /bar/foo/magic, I see the magic word. However, I would also like to use /foo/bar/magic, and also receive the magic word. This latter case doesn't work, the magic_word isn't set. In fact, the "client" argument is never anything but None. This is a facet of Zope I still don't quite understand... Thanks, -Randy
Figured this out, with the zope-dev archives. In case anyone else bumps into the same thing, the FunctionTemplate class at http://www.zope.org/Members/htrd/howto/FunctionTemplate is very helpful. -Randy ----- Original Message ----- From: Randall Kern To: zope@zope.org Sent: Sunday, November 26, 2000 8:17 PM Subject: [Zope] client argument to python function calls? I'm trying to emulate some DTML methods with python code in my (python) product. Let's say I have two Python classes, one named Foo, the other Bar. Something like this: class Foo(Folder.Folder, Persistent, Implicit): meta_type = "Foo" def magic(self, client=None): "magic method!" if client == None: client = self return client.magic_word class Bar(Folder.Folder, Persistent, Implicit): meta_type = "Bar" def __init__(self, id): self.id = id self.magic_word = 'Alacazam!" Now I create a structure like this in Zope: / foo (instance of the Foo class) bar (instance of the Bar class) Now if I goto /bar/foo/magic, I see the magic word. However, I would also like to use /foo/bar/magic, and also receive the magic word. This latter case doesn't work, the magic_word isn't set. In fact, the "client" argument is never anything but None. This is a facet of Zope I still don't quite understand... Thanks, -Randy
participants (1)
-
Randall Kern