[Zope] Get caller context
Peter Sabaini
peter at sabaini.at
Wed Apr 7 09:20:50 EDT 2004
I'd pass the caller explicitly, eg.:
in the Product:
class MyClass(...):
def myMethod(self, caller=None, ...):
if caller is None: caller = self
# do stuff with caller, eg. get a property:
v = caller.some_property
# ...
in folderMethod (ZPT):
<span tal:replace="python:here.myObject(caller=container, ... )" />
Dragos Chirila wrote:
> Hi
>
> I want to identify the object from where the call is made.
>
> In my example the "caller" is the 'folder' object.
>
> Regards
> Dragos
>
>
>
>>Please clarify: do you want to call the myMethod() method or are you
>>talking of a HTTP Redirect?
>>
>>Referer != Caller
>>
>>
>>Dragos Chirila wrote:
>>
>>>Hi All
>>>
>>>I have a folderish python object that has a method.
>>>I want to be able to call this method using the context of the place I
>
> call
>
>>>it from and not the place where the method is.
>>>
>>>Example:
>>> ROOT
>>> -----/ myObject (has a python method named myMethod)
>>> -----/ folder
>>> ----/folderMethod (ZPT)
>>>
>>>I call myMethod of the myObject from the folderMethod of the folder
>
> object.
>
>>>I want to execute myMethod in the context of the folder object.
>>>
>>>I don't want to use REQUEST['HTTP_REFERER'].
>>>
>>>How can I identify the caller(referer) object of the myMethod?
>>>
>>>Thanks a lot,
>>>Dragos
>>>
>>>
>>>
>>>_______________________________________________
>>>Zope maillist - Zope at zope.org
>>>http://mail.zope.org/mailman/listinfo/zope
>>>** No cross posts or HTML encoding! **
>>>(Related lists -
>>> http://mail.zope.org/mailman/listinfo/zope-announce
>>> http://mail.zope.org/mailman/listinfo/zope-dev )
>>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3216 bytes
Desc: S/MIME Cryptographic Signature
Url : http://mail.zope.org/pipermail/zope/attachments/20040407/6aa9936a/smime.bin
More information about the Zope
mailing list