[Zope] Python equivalent to PythonScript context binding?

Johan Carlsson johanc at virtutech.com
Mon Aug 30 05:49:14 EDT 2004


Bill Hewitt wrote:

>my python class method cannot seem to find any bindings- container,
>context, etc...
>
>Do I have to do something to help the class find these bindings?
>(Bear with me, I am weening off of ZClasses and DTML....)
>  
>
Python methods don't have the bindings of container and context etc.
The Python object it self have a wrapped acquisition context where
you can access the context directly from self  and it's parents
from aq_parent(self) or aq_parent(aq_inner(self)) which gives it
the parent of container context (in acquisition the context can be
modified like the dtml-with tag does using the __of__ method.)

Also if a method should be callable TTW it should define
client, REQUEST=None as the first arguments.
REQUEST is actually accessible from the acquisition context
of self now days enabling self.REQUEST to be used.
And client is very seldom used to my knowledge.

Also if DTML calles DTML be sure to call it with
the mapping object, e.g. "dtml_method(_.None, _)".
Also calling from Python include the self and REQUEST,
like this: dtml_method(self, REQUEST=REQUEST)

Hope this helps you.
Regards,
Johan Carlsson


More information about the Zope mailing list