[Zope-dev] Can't get ZClass baseclass to behave as DTML Metho d

Michel Pelletier michel@digicool.com
Wed, 8 Sep 1999 14:07:38 -0400


> -----Original Message-----
> From: Martijn Faassen [mailto:m.faassen@vet.uu.nl]
> Sent: Wednesday, September 08, 1999 11:45 AM
> To: zope-dev@zope.org
> Subject: [Zope-dev] Can't get ZClass baseclass to behave as 
> DTML Method
> 
> 
> Hi there again,
> 
> Python and DTML Methods, one way or another they seem to be the theme
> for me today..
> 
> A couple of weeks ago I asked the same question (I encountered it in
> different circumstances). I'm trying to create a ZClass 
> (deriving from a
> Python base class) that behaves like a DTML _method_.
> 
> To this purpose, I tried to define this __call__:
> 
> def __call__(self, client, REQUEST=None):
>     "Call this ZClass as a DTML method."
>     return self.render(client, REQUEST)
> 
> in the base class that is inherited by a ZClass.
> 
> If I grok the answers I got today by Martijn Pieters and Evan Simpson
> right, the arguments mean the following:
> 
> self - the instance of this ZClass
> client - the object we're calling this method on (in my case an XML
> node)
> REQUEST - the regular request object
> 
> the 'render' function figures out how to display the node (client) and
> returns the resulting string.
> 
> This is however not working -- if I call an instance 'foo' 
> like this on
> an XML node, like this:
> 
> xmldoc/e7/e14/foo
> 
> instead it'll display index_html (that is acquired and not defined on
> the ZClass). It apparently isn't calling __call__ at all.

It doesn't call *your* __call__ or it raises an exception?

It might be calling a __call__ method defined in a Base class that
supercedes the one you define.

-Michel