RE: [Zope-dev] Can't get ZClass baseclass to behave as DTML Metho d
-----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
Michel Pelletier wrote: [big snip of my problem description]
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?
Oh, right, I meant *my* __call__. Obviously it's calling *some* call somewhere, i.e. the one of the folder's index_html. No exceptions; it just displays the index_html that is defined for the folder taht the XML document is in.
It might be calling a __call__ method defined in a Base class that supercedes the one you define.
What is looks like is that my ZClass simply doesn't find my __call__ (defined in my python base class for it) and looks it up by the acquisition machinery instead. Is this a bug, then, or is it meant to be this way? If it's meant to be like this, why? :) Regards, Martijn
participants (2)
-
Martijn Faassen -
Michel Pelletier