Bugs item #1378359, was opened at 2005-12-12 01:52
Message generated for change (Comment added) made by phd
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1378359&group_id=74338
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: General
Group: SQLObject from repository
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
>Assigned to: Oleg Broytmann (phd)
Summary: Col does not call object's __init__()?
Initial Comment:
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
lil...@gm...
----------------------------------------------------------------------
>Comment By: Oleg Broytmann (phd)
Date: 2006-01-03 17:02
Message:
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!
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1378359&group_id=74338
|