##// END OF EJS Templates
Draft of debugging the multiple inheritance problems in km....
Brian Granger -
Show More
@@ -10,7 +10,13 b' from IPython.zmq.kernelmanager import KernelManager, SubSocketChannel, \\'
10 10 XReqSocketChannel, RepSocketChannel
11 11 from util import MetaQObjectHasTraits
12 12
13
13 # When doing multiple inheritance from QtCore.QObject and other classes
14 # the calling of the parent __init__'s is a subtle issue:
15 # * QtCore.QObject does not call super so you can't use super and put
16 # QObject first in the inheritance list.
17 # * QtCore.QObject.__init__ takes 1 argument, the parent. So if you are going
18 # to use super, any class that comes before QObject must pass it something
19 # reasonable.
14 20
15 21 class QtSubSocketChannel(SubSocketChannel, QtCore.QObject):
16 22
@@ -106,7 +112,6 b' class QtRepSocketChannel(RepSocketChannel, QtCore.QObject):'
106 112 QtCore.QObject.__init__(self)
107 113 RepSocketChannel.__init__(self, *args, **kw)
108 114
109
110 115 class QtKernelManager(KernelManager, QtCore.QObject):
111 116 """ A KernelManager that provides signals and slots.
112 117 """
@@ -124,6 +129,10 b' class QtKernelManager(KernelManager, QtCore.QObject):'
124 129 xreq_channel_class = QtXReqSocketChannel
125 130 rep_channel_class = QtRepSocketChannel
126 131
132 def __init__(self, *args, **kw):
133 QtCore.QObject.__init__(self)
134 KernelManager.__init__(self, *args, **kw)
135
127 136 #---------------------------------------------------------------------------
128 137 # 'KernelManager' interface
129 138 #---------------------------------------------------------------------------
@@ -11,6 +11,7 b' from IPython.utils.traitlets import HasTraits'
11 11 MetaHasTraits = type(HasTraits)
12 12 MetaQObject = type(QtCore.QObject)
13 13
14 # You can switch the order of the parents here.
14 15 class MetaQObjectHasTraits(MetaQObject, MetaHasTraits):
15 16 """ A metaclass that inherits from the metaclasses of both HasTraits and
16 17 QObject.
@@ -18,8 +19,9 b' class MetaQObjectHasTraits(MetaQObject, MetaHasTraits):'
18 19 Using this metaclass allows a class to inherit from both HasTraits and
19 20 QObject. See QtKernelManager for an example.
20 21 """
21
22 def __init__(cls, name, bases, dct):
23 MetaQObject.__init__(cls, name, bases, dct)
24 MetaHasTraits.__init__(cls, name, bases, dct)
22 # pass
23 # ???You can get rid of this, but only if the order above is MetaQObject, MetaHasTraits
24 # def __init__(cls, name, bases, dct):
25 # MetaQObject.__init__(cls, name, bases, dct)
26 # MetaHasTraits.__init__(cls, name, bases, dct)
25 27
@@ -385,6 +385,7 b' class KernelManager(HasTraits):'
385 385 self._rep_address = (LOCALHOST, 0) if rep_address is None else rep_address
386 386 self.context = zmq.Context() if context is None else context
387 387 self.session = Session() if session is None else session
388 super(KernelManager, self).__init__()
388 389
389 390 #--------------------------------------------------------------------------
390 391 # Channel management methods:
General Comments 0
You need to be logged in to leave comments. Login now