[Zope] How to get "context" in an instance method
Dieter Maurer
dieter@handshake.de
Wed, 6 Mar 2002 22:53:13 +0100
Paul Tiemann writes:
>
> This probably has a simple solution, but I'm probably going to have to sleep
> on it to find it. Thanks in advance for any help...
>
> I have a class derived from ObjectManager and SimpleItem.Item which defines
> a directory structure under it. Something like this:
>
> class MyZopeProduct( ObjectManager.ObjectManager, SimpleItem.Item )
> # ...
> def myFunc(self, context=None, REQUEST=None):
> doSomethingWithContext(context)
>
> After I add an instance of MyZopeProduct to my root folder (as myinstance) I
> can go
> to http://me:8080/myinstance and things work as expected. If there is a
> folder inside my instance called 'folder' then I can also go to
> http://me:8080/myinstance/folder and everything works fine.
>
> What I can't figure out is how to go to
> http://me:8080/myinstance/folder/myFunc and have the context (the folder
> instance object) passed into my script.
You can try: "self.aq_parent".
It's not sure, that it will work, though. If it does not,
you could use a "ComputedAttribute(myFunc,1)" and pass the information
explicitly.
Dieter