[Zope-dev] ZClasses as *methods*
Phillip J. Eby
pje@telecommunity.com
Wed, 25 Aug 1999 12:43:34 -0500
At 02:44 PM 8/25/99 +0200, Martijn Faassen wrote:
>
>But, I can't seem to be able to write a ZClass that does this. I try
>inheriting from a Python base class and overriding __call__, but the
>resulting objects don't behave like DTML Methods -- 'self' becomes the
>instance of that object, instead of the XML Document I'm working on,
>like it is with DTML Methods.
>
>So, what makes DTML Methods special? Am I going about the right route at
>all? Any suggestions at all would be very welcome.
>
Try making your __call__ signature:
def __call__(me,self,...):
And use 'me' to refer to the instance, self to refer to the object called
with.
Alternatively, just use REQUEST.PARENTS[0] to refer to the object you're a
method of. See the DTML User's Guide. (This only works if the method is
called from the web, though.)