Re: [Zope-dev] Patching object class

2003-06-20 Thread Dieter Maurer
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

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Patching object class

2003-06-20 Thread Florent Guillaume
Sidnei da Silva wrote:
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
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:[EMAIL PROTECTED]
___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Patching object class

2003-06-20 Thread Florent Guillaume
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:[EMAIL PROTECTED]
___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Patching object class

2003-06-20 Thread Sidnei da Silva
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) <[EMAIL PROTECTED]>
X3ng Web Technology 
GNU/Linux user 257852
Debian GNU/Linux 3.0 (Sid) 2.4.20-powerpc ppc

You're already carrying the sphere!

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Patching object class

2003-06-20 Thread Paul Winkler
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)

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] Patching object class

2003-06-20 Thread Florent Guillaume
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:[EMAIL PROTECTED]
___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )