[ZODB-Dev] Persistent sub-objects: noob question
Jeremy Hylton
jeremy at zope.com
Sat Jan 17 17:42:26 EST 2004
On Sat, 2004-01-17 at 17:31, Paul Winkler wrote:
> Given this class:
>
> class Foo(Persistent):
> def __init__(self):
> self.bar = OOBTree()
>
> def store(self, key, value):
> self.bar[value] = key
> self._p_changed = 1 # redundant
>
> The line I'm wondering about is the last one.
> I know it's not *useful* since I've only changed an OOBTree...
> But is it *harmless* to leave that line in? What exactly
> happens? I've been looking at Connection.py but I can't
> really see what happens:
>
> - Does it unnecessarily cause a copy of the whole Foo
> instance to be saved?
Yes.
> - Or does it cause an unnecessary copy of the entire OOBTree
> to be saved?
No. The BTree is already marked as change. More specifically, some
part of the BTree is marked as changed. For a large tree, it will
usually mark just a single bucket as changed.
> - Or is ZODB so cool that nothing is done? :-)
It's so cool that it does just what you tell it :-).
Jeremy
More information about the ZODB-Dev
mailing list