[Zope] Problems with inheritance in python base products
Martijn Pieters
mj@antraciet.nl
Sun, 17 Oct 1999 07:28:33 +0200
At 04:06 17-10-99 , Sascha Matzke wrote:
>Hello,
>
>I want to design 2+ products which all share certain base
>functionality. So I moved some code into Shared.
>
>Now, when I try to create instances of the products I get the
>following error:
>
>Error Type: TypeError
>Error Value: unbound method must be called with class instance 1st
> argument
>
>I use the following code:
>
>class B(A):
>
> def __init__(self, some, more, parameters):
> A.__init__(self, some, more)
>
>In my python knowlegde the above should be correct...
This is either caused by ExtensionClass or acquisition, I never bothered to
get to the heart of it. It basically confuses the Python interpreter into
not seeing the proper class hierarchy, and throwing above tantrum. The
solution is simple: call .im_func() to use the unbound method:
def __init__(self, some, more, parameters):
A.__init__.im_func(self, some, more)
--
Martijn Pieters, Web Developer
| Antraciet http://www.antraciet.nl
| T: +31 35 7502100 F: +31 35 7502111
| mj@antraciet.nl http://www.antraciet.nl/~mj
| PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149
---------------------------------------------