[Zope-dev] Patching object class

Sidnei da Silva sidnei@x3ng.com
Fri, 20 Jun 2003 13:36:05 -0300


On Fri, Jun 20, 2003 at 04:56:26PM +0200, Florent Guillaume wrote:
| 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 ?
| 
| If not, what other hack could I do ? The idea being that I don't want to 
| recreate all the objects.

You need something like this:

http://cvs.zope.org/Products/ZopeOrg-NV/Extensions/change_modules.py?rev=1.2&cvsroot=Zope.org&content-type=text/vnd.viewcvs-markup

BIG BOLD WARNING: 
=================

Backup your data before using it.

[]'s
-- 
Sidnei da Silva (dreamcatcher) <sidnei@x3ng.com.br>
X3ng Web Technology <http://www.x3ng.com.br>
GNU/Linux user 257852
Debian GNU/Linux 3.0 (Sid) 2.4.20-powerpc ppc

You're already carrying the sphere!