For me it's a problem with ExtensionClasses and, to me, there is no way to make it work. In [11]: from ExtensionClass import Base In [12]: class r(Base) : pass ....: In [13]: class e : pass ....: In [14]: d.__class__ Out[14]: <extension class __main__.r at 82b9cf0> In [15]: d.__class__ = e In [16]: d.__class__ Out[16]: <extension class __main__.r at 82b9cf0> In [17]: class e(Base) : pass ....: In [18]: d.__class__ = e In [19]: d.__class__ Out[19]: <extension class __main__.r at 82b9cf0> I will use the good pattern if it's a piece of your conception to work with 'objects that mutate to other objects', but what do you really need (i.e. it is not the good way to upgrade products, see the ZDG - Chapter 3: Zope Products - Evolving Products) ? Max M a écrit :
I have a bunch of objects in the ZODB that I need to convert to other objects.
The new object have the same meta_type and the same attributes. But they are of a new class.
So I thought that I could simply assign a new class.
I tried assigning the new class to __class__ but that didn't work. Like::
obj.__class__ = SomeNewClass
I suspect that is because I am assigning it to an aquisition wrapper. But I am not shure.
Would I need to do something like?
base = obj.aq_base base.__class__ = SomeNewClass