[Zope-dev] Patching object class

Dieter Maurer dieter@handshake.de
Fri, 20 Jun 2003 21:01:26 +0200


Florent Guillaume wrote at 2003-6-20 16:56 +0200:
 > I have the need to "update" some persistent objects in a ZODB to change 
 > their class.
 > 
 > One use case comparable to the one I have would be to change all objects 
 > of type Folder to OrderedFolder.
 > To do that, I envisionned finding all thoses objects and doing
 > 
 >    ob.__class__ = OrderedFolder
 >    ob._p_changed = 1
 > 
 > Would this work ?

It will not work (at least it did not when I last tried it).
The "__class__" assignment was simply ignored (no error, it was just
that the class did not change).

 > If not, what other hack could I do ? The idea being that I don't want to 
 > recreate all the objects.

I follow Maik: Give "OFS.Folder.Folder" (or even "ObjectManager")
"Orderable" support.


Dieter