Re: Objects with varying classes

Manuel Reinhardt <[email protected]> Wed, 26 Sep 2018 15:53:24 +0200
Newsgroups gmane.comp.web.zope.zodb
Message-ID <CAHj+0u4bat0TyznFERYOBHetjEDgJb0n3=uApu=G4MsQHjygbQ@mail.gmail.com>
> So to change the class of the object, you have to set item._p_changed =
True  for all of the objects that refer to the the object on which you
changed the class.

That makes sense. I don't get why this doesn't work in the code above
though - I modify ref, then set ref._p_changed, but after a restart my
modification is gone.

However, I tried exchanging it completely; i.e. creating a new ref by
calling IKeyReference(obj) and assigning that to the BTree (intids.ids),
and that seems to work.

> As for BTrees, if they get changed, then the buckets get saved.
Otherwise they would not work.

I was thinking of an object inside the BTree being changed, not the BTree
itself. In my example above I would retrieve a KeyReferenceToPersistent
object from the BTree and make some change on it. I was wondering whether
it has any impact on persistence that the object is apparently not saved
directly in the BTree but in a Bucket.

Anyway, thanks, I think I got another step further!

Manuel


On Wed, 26 Sep 2018 at 14:59, Christopher Lozinski <
[email protected]> wrote:

> Here is my two cents.
>
> I recently looked at teh set state methods in class persistent.
> They have the database id of the object, and the database of the object.
>
> So to change the class of the object, you have to set item._p_changed =
> True  for all of the objects that refer to the the object on which you
> changed the class.
>
> You only saved the object, not the reference to it, so there was trouble.
>   At least that is my guess.
>
> As for BTrees, if they get changed, then the buckets get saved.  Otherwise
> they would not work.
>
> Hope that helps.
>
> Chris
>

-- 
You received this message because you are subscribed to the Google Groups "zodb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.