[Zope] Help subclassing a non Zope class as base class of a product

Gilles Lenfant gilles@objectis.net
Tue, 21 May 2002 20:28:56 +0200


Hi,

Thanks Max, but it seems to work only if the base class is a "root" =
class (does not inherit of an other one).

In my case, I have...

<SNIP>
from UserList import UserList
class Myclass(UserList):
    def __init__(self, data=3D[]):
        ...
        # Exception raises from here now!!!
        UserList.__init__(self, data)
    ...

class ZMyClass(SimpleItem, MyClass):
    ...
    def __init__(self, id, title=3D''):
        ...
        ZMyClass.inheritedAttribute('__init__')(self)
...
</SNIP>

I could rework my code to have...

class ZMyClass(SimpleItem, MyClass, UserList):
...

But in that case (multiple __init__ due to multiple inheritance) WHERE =
does the inheritedAttribute finds the method.

Is there some doc for Python product programmers where I could find =
other APIs guides ?
There's - approximately - nothing for this in the Zope book.
I did not find anything and hack other's code doing things other do =
whithout knowing why.
In example, I did not find the difference between initializeClass and =
initializeBaseClass.

Thanks again.

--Gilles

----- Original Message -----=20
From: "Max M" <maxm@mxm.dk>
To: "Gilles Lenfant" <gilles@objectis.net>
Cc: <zope@zope.org>
Sent: Tuesday, May 21, 2002 4:05 PM
Subject: Re: [Zope] Help subclassing a non Zope class as base class of a =
product
:=20
: As far as I remember you should:
:=20
: class myObject(ObjectManager)  =20
:   =20
:     def __init__(self, id):
:         "Inits the object"
:         myObject.inheritedAttribute('__init__')(self, id)
:=20
: Anyhoo you can google on "inheritedAttribute" and stuff should show =
up.
:=20
: regards Max M
:=20
:=20
:=20
: _______________________________________________
: Zope maillist  -  Zope@zope.org
: http://lists.zope.org/mailman/listinfo/zope
: **   No cross posts or HTML encoding!  **
: (Related lists -=20
:  http://lists.zope.org/mailman/listinfo/zope-announce
:  http://lists.zope.org/mailman/listinfo/zope-dev )
:=20