Hmm.. I know this is a python question, but DejaNews nor the Python website give me the answers I am looking for: I define a baseclass derived from CatalogAware and DTMLMethod: class Base(CatalogAware, DTMLMethod): def index_object(self): # check a few things I want to know about # before indexing, maybe even not allowing # the indexing CatalogAware.index_object(self) Then I define a bunch of classes based on this base class: class A(Base): pass class B(Base): pass etc. Now, if I do the following: a=A() a.index_object() I get a TypeError: unbound method must be called with class instance 1st argument Now, I have seen all sorts of messages relating this error, but none of them seem to relate to my problem... self in Vase.index_object _is_ a class instance, a step-by-step debug proves this. The python interpreter just won't accept it =(. -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
At 01:40 PM 9/9/99 +0200, Martijn Pieters wrote:
Hmm.. I know this is a python question, but DejaNews nor the Python website give me the answers I am looking for:
I define a baseclass derived from CatalogAware and DTMLMethod:
class Base(CatalogAware, DTMLMethod): def index_object(self): # check a few things I want to know about # before indexing, maybe even not allowing # the indexing CatalogAware.index_object(self)
The last line may be your problem. Try: CatalogAware.index_object.im_func(self) This construct is often required when calling base class methods from an ExtensionClass deriviative. You will sometimes get an error such as you describe, when performing such a call, because the type Python thinks something is may be different if the thing is in an acquisition wrapper or is an ExtensionClass when the base class is NOT based on an ExtensionClass. Pretty much I make it a habit in all my Python to use the .im_func() construct for calling base class methods, because then I never have to worry about what kind of objects I'm using.
At 14:06 09/09/99 , Phillip J. Eby wrote:
At 01:40 PM 9/9/99 +0200, Martijn Pieters wrote:
Hmm.. I know this is a python question, but DejaNews nor the Python website give me the answers I am looking for:
I define a baseclass derived from CatalogAware and DTMLMethod:
class Base(CatalogAware, DTMLMethod): def index_object(self): # check a few things I want to know about # before indexing, maybe even not allowing # the indexing CatalogAware.index_object(self)
The last line may be your problem. Try:
CatalogAware.index_object.im_func(self)
Thank you Philip. This was the magic I was missing. I knew it'd be something like that. -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
participants (2)
-
Martijn Pieters -
Phillip J. Eby