#139 Col does not call object's __init__()?

closed-fixed
Oleg Broytman
General (125)
5
2006-01-03
2005-12-11
Anonymous
No

I'm using ver 0.7 (downloaded it from SourceForge, I think)

I've had problems creating subclasses of StringCol (my
goal is to make the columns able to return GUI
components based on their type). My class definitions
look like this:

class NewChild(StringCol, SomeGUIMixIn):
def __init__(...):
super(NewChild, self).__init__(...)

The problem is: The constructor of SomeGUIMixIn (and
its superclasses) are never called by this statement.
I've searched the web looking for similar problems, and
it seems that this is related to the way super() works
with multiple inheritance. In my class declaration, it
wold start by calling the constructor of the leftmost
superclass (i.e. StringCol), go down it's entire
inheritance tree to object, and then proceed to the
next superclass in the definition (in this example
SomeGUIMixIn) and go down that tree to object. The
problem occurs if some superclass forgets to call the
one of it's own superclass's constructors. Then the
chain is broken, and no more constructors will be called.

It seems to me that this is the problem here. I checked
the source code availible via the API, and Col, a
direct subclass of object, never seems to call
object.__init__() (or the equivalent "super(Col,
self).__init__()"). This should be easy to fix? (my
suspicion is strengthened by the fact that if I reverse
the order of the superclasses of NewChild in it's
declaration to "class NewChild(SomeGUIMixIn,
StringCol)", at least my constructor in SomeGUIMixIn
and it's superclasses are called.

Please correct me if I'm wrong! I'm not experienced
with Python.

Best regards,
Jostein Bø Fløystad
lillejostein@gmail.com

Discussion

  • Oleg Broytman
    Oleg Broytman
    2006-01-03

    • assigned_to: nobody --> phd
    • status: open --> closed-fixed
     
  • Oleg Broytman
    Oleg Broytman
    2006-01-03

    Logged In: YES
    user_id=4799

    Yes, you are right. I changed all Parent.__init__(super)
    calls to super(ClassName, self).__init__() and added such a
    call to Col and SOCol classes. That should fix your problem.

    Commited at the revision 1456 and backported to 0.7-branch.
    Thank you for the inspiration!