"metaclass conflict" error: where is noconflict ?
Barak, Ron
Ron.Barak at lsi.com
Sun Feb 22 04:37:38 EST 2009
Hi Chris,
> -----Original Message-----
> From: chris at rebertia.com [mailto:chris at rebertia.com] On
> Behalf Of Chris Rebert
> Sent: Thursday, February 19, 2009 22:58
> To: Barak, Ron
> Cc: python-list at python.org; wxpython-users at lists.wxwidgets.org
> Subject: Re: "metaclass conflict" error: where is noconflict ?
>
> On Thu, Feb 19, 2009 at 5:01 AM, Barak, Ron <Ron.Barak at lsi.com> wrote:
> > Hi,
> >
> > I have a class derived from two parents (in blue below),
> which gives
> > me the following error:
> >
> > $ python -u ./failover_pickle_demo09.py Traceback (most recent call
> > last):
> > File "./failover_pickle_demo09.py", line 291, in <module>
> > class ListControl(wx.Frame, CopyAndPaste):
> > TypeError: Error when calling the metaclass bases
> > metaclass conflict: the metaclass of a derived class must be a
> > (non-strict) subclass of the metaclasses of all its bases Googling
> > suggested I should add from noconflict import classmaker and
> >
> > __metaclass__=classmaker()
> > to this class.
> >
> > However, I don't seem able to find where to get the
> noconflict module from.
> >
> > Do any of you where noconflict could be downloaded/installed from ?
>
> From what I could google, you should in theory be able to fix
> the problem (without using any 3rd party module) by doing:
>
> class ListControlMeta(type(wx.Frame), type(CopyAndPaste)):
> pass
>
> class ListControl(wx.Frame, CopyAndPaste):
> __metaclass__ = ListControlMeta
> #rest of class...
>
> Cheers,
> Chris
Applying your suggestion:
class ListControlMeta(type(wx.Frame), type(CopyAndPaste)):
pass
class ListControl(wx.Frame, CopyAndPaste):
def __init__(self, parent, id, title, list, max_list_width, log_stream, style=wx.DEFAULT_FRAME_STYLE):
__metaclass__= ListControlMeta
wx.Frame.__init__(self,parent,id,title,size=(max_list_width,-1), style=style)
self.list = list
self.log_stream = log_stream
self.list_ctrl = wx.ListCtrl(self, -1, style=wx.LC_REPORT | wx.LC_NO_HEADER)
self.list_ctrl.InsertColumn(0, title)
for i,line_ in enumerate(list):
self.list_ctrl.InsertStringItem(i, line_)
...
I get:
$ python -u ./failover_pickle_demo09.py
Traceback (most recent call last):
File "./failover_pickle_demo09.py", line 319, in <module>
class ListControlMeta(type(wx.Frame), type(CopyAndPaste)):
TypeError: Error when calling the metaclass bases
multiple bases have instance lay-out conflict
So, back to trying to understand...
Thanks and bye,
Ron.
>
> --
> Follow the path of the Iguana...
> http://rebertia.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090222/ecd771a7/attachment-0001.html>
More information about the Python-list
mailing list