[Zope-dev] Patching object class
Paul Winkler
pw_lists@slinkp.com
Fri, 20 Jun 2003 12:31:43 -0400
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)