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. Florent -- Florent Guillaume, Nuxeo (Paris, France) +33 1 40 33 79 87 http://nuxeo.com mailto:fg@nuxeo.com
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.
Maybe you should install OrderedObjectManager for bringing order to all your folders. http://www.zope.org/Members/mjablonski/OrderedObjectManager I'll release an api-updated version when 2.7 is released. Cheers, Maik
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 ?
See the thread "Renaming a product" just a few days ago. The conclusion was that this would not work.
If not, what other hack could I do ? The idea being that I don't want to recreate all the objects.
You might not have a choice. A conversion script might take a while to run and your ZODB might get a bit more bloated, but otherwise, it'll work fine. -- Paul Winkler http://www.slinkp.com Look! Up in the sky! It's ULTRA BULLET FROGMAN! (random hero from isometric.spaceninja.com)
Paul Winkler wrote:
To do that, I envisionned finding all thoses objects and doing
ob.__class__ = OrderedFolder ob._p_changed = 1
Would this work ?
See the thread "Renaming a product" just a few days ago. The conclusion was that this would not work.
Ok, but I'm curious about the deeper reason. Why is the class given a special treatment in the ZODB ? If an object has changed, it has to be re-dumped to storage, and I guess this includes its class. Or is the class used as metadata somewhere along the oid ? Florent -- Florent Guillaume, Nuxeo (Paris, France) +33 1 40 33 79 87 http://nuxeo.com mailto:fg@nuxeo.com
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... 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!
Sidnei da Silva wrote:
You need something like this:
http://cvs.zope.org/Products/ZopeOrg-NV/Extensions/change_modules.py?rev=1.2...
Thanks, I see there is indeed some deep voodoo involved... Florent -- Florent Guillaume, Nuxeo (Paris, France) +33 1 40 33 79 87 http://nuxeo.com mailto:fg@nuxeo.com
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
participants (5)
-
Dieter Maurer -
Florent Guillaume -
Maik Jablonski -
Paul Winkler -
Sidnei da Silva