[Chris Withers]
> Sorry, my question was that if DateTime's were persistent, would the
> following code result in a complete pickle for 'a' being written on the
> second transaction commit?

There is only one commit in the following, so I'll assume you intended a
second commit at the end:

> a.someTime = DateTime()
> get_transaction().commit()

Is `a` persistent?  I'm assuming that it is.

> ...wait/do stuff...
> a.someTime = DateTime()

I'm assuming another

    get_transaction().commit()

was intended here.

> ...have we just committed a pickle containing all of 'a'?...

If `a` is persistent, yes.

> Does mixing persistence into DateTime make a difference here?

No.  Assuming `a` is persistent, you changed `a`, so `a`'s state gets
written out.  This really has nothing to do with DateTime.  It would be the
same answer had you done, e.g.,

    a.someTime = None

or

    a.someTime = "hi!"

or

    a.someTime = OOBTree()

instead.

One part is different:  if DateTime is not persistent, then the pickle for
a's state includes the full state of a.someTime's DateTime attribute (and
this is true for any attribute of any non-persistent type).  But if DateTime
is persistent, then a.someTime is pickled as a distinct object, and the
state for `a` contains only a reference to that distinct pickle (and again
this is true for any attribute of any persistent type).  a's full state is
pickled regardless.  The difference is in whether a's full state embeds
a.someTime's state directly, or "points to" a distinct pickle for
a.someTime's state.

If the same DateTime object is referenced by many persistent objects, there
can be major storage efficiencies is making DateTime persistent, because the
"many other objects" can all point to the same pickle.  I don't know, but I
doubt that's a likely scenario for DateTime objects.

_______________________________________________
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev

Reply via email to