Hi Michele,
I tried understanding how to avoid the metaclasses clashing, and I did read the
link you referred to below,
as well as the relevant O'Reilly cookbook chapter (Recipe 20.17. Solving
Metaclass Conflicts), but seems I do not understand the correct syntax to use,
as I either get
$ python -u ./failover_pickle_demo09.py
Traceback (most recent call last):
File "./failover_pickle_demo09.py", line 323, in <module>
class ListControlMeta(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
or
$ python -u ./failover_pickle_demo09.py
Traceback (most recent call last):
File "./failover_pickle_demo09.py", line 322, in <module>
class ListControlMeta(type(wx.Frame), type(CopyAndPaste)):
TypeError: Error when calling the metaclass bases
multiple bases have instance lay-out conflict
And, mind you, all I wanted to do was inherit from two classes: wxPython's
wx.Frame and my CopyAndPaste.
Namely -
I have a subclass of wxPython's wx.Frame called ListControl.
I wanted to add copy (from copy-and-paste) capabilities to this ListControl
class.
I changed the header of this class to be:
class ListControl(wx.Frame, CopyAndPaste):
But, the addition of CopyAndPaste to the class parents got me into this
quagmire of metaclasses.
Bye,
Ron.
> -----Original Message-----
> From: Michele Simionato [mailto:[email protected]]
> Sent: Friday, February 20, 2009 07:23
> To: [email protected]
> Subject: Re: "metaclass conflict" error: where is noconflict ?
>
> On Feb 19, 9:58 pm, Chris Rebert <[email protected]> wrote:
> > On Thu, Feb 19, 2009 at 5:01 AM, Barak, Ron
> <[email protected]> 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 ?
>
>
> It refers to this cookbook recipe:
> http://code.activestate.com/recipes/204197/
>
> See also the printed cookbook:
>
> http://books.google.it/books?id=1Shx_VXS6ioC&pg=PA786&lpg=PA78
6&dq=python+cookbook+noconflict&source=bl&ots=BB413AZ8R7&sig=cnAB-E9rNFolHBEZQTIm_d4Mj3o&hl=it&ei=GT2eSfCtBdWa_gadppHYCw&sa=X&oi=book_result&resnum=2&ct=result#PPA786,M1
However, there is no module to download, and this is on purpose:
instead of blindly apply a "fix" one should understand what the conflict is:
then it is quite easy to solve it by hand. The recipe discussion explains it
all.
--
http://mail.python.org/mailman/listinfo/python-list