(Adding zodb-dev@zope.org back to Cc:)

On Thu, Jul 03, 2008 at 09:14:27AM -0400, Erik Dahl wrote:
> On Jul 2, 2008, at 10:55 AM, Marius Gedminas wrote:
> >>
> >>inst.__class__ = NewClass
> >
> >Is inst a persistent object?  Then your only chance to get this to  
> >work
> >is to find *all* objects that reference inst and mark them _p_changed.
> Yes inst is a persistent object.  Hum ok I will give this a try.
> >
> >>The class is also stored in every reference to that object.
> Well that something new to me... how come?  Seems like they only need  
> the oid.

My guess is that's for performance reasons.  When you load the state of
an object X with an attribute 'y' referring to object Y, you end up with
two objects in memory: X with all of its state, and Y which is a "ghost"
(it only knows its own class and oid).  To create the ghost you need to
know its class.  To avoid loading the pickle of Y when you only need X,
every reference to Y stores both its oid and its class.

If you look at ZODB/serialize.py and look at ObjectWriter.persistent_id,
you'll see it stores references to persistent objects as (oid, class)

Marius Gedminas
> find /lib/modules/2.4.17-expt/kernel/ -type f|while read i; do insmod $i; done
You're sick.  I like you.
        -- Andrew Morton on lkml

Attachment: signature.asc
Description: Digital signature

For more information about ZODB, see the ZODB Wiki:

ZODB-Dev mailing list  -  ZODB-Dev@zope.org

Reply via email to