Patrick Dobbs
2009-10-13 13:07:19 UTC
Hi,
I've a class which subclasses PersistentList and which has a mixin:
class Confused(PersistentList,MyMixin):
def __init__(self,*args,**kwds):
#init stuff
super(Confused,self).__init__(*args,**kwds)
Previously, it subclassed PersistentObject and all worked fine. When I
changed it to subclass PersistentList I found that that MyMixin was not
initialising. This seems to be because PersistentList defines an
__init__ method which doesn't call super() whereas PersistentObject
doesn't define an __init__ method at all.
This seems to be fixed by the addition of:
super(PersistentList,self).__init__(*args,**kwargs)
on line 18 in PersistentList.
Presumably the same issue would occur with PersistentDict.
Is this behaviour by design, or would it be a good idea to add these
super() inits calls to the Persistent classes so they play well with
subclasses?
Thanks very much, by the way, for developing and maintaining durus. It's
a pleasure to work.
Regards
Patrick
I've a class which subclasses PersistentList and which has a mixin:
class Confused(PersistentList,MyMixin):
def __init__(self,*args,**kwds):
#init stuff
super(Confused,self).__init__(*args,**kwds)
Previously, it subclassed PersistentObject and all worked fine. When I
changed it to subclass PersistentList I found that that MyMixin was not
initialising. This seems to be because PersistentList defines an
__init__ method which doesn't call super() whereas PersistentObject
doesn't define an __init__ method at all.
This seems to be fixed by the addition of:
super(PersistentList,self).__init__(*args,**kwargs)
on line 18 in PersistentList.
Presumably the same issue would occur with PersistentDict.
Is this behaviour by design, or would it be a good idea to add these
super() inits calls to the Persistent classes so they play well with
subclasses?
Thanks very much, by the way, for developing and maintaining durus. It's
a pleasure to work.
Regards
Patrick