[ZODB-Dev] zodb4: adding an object before transaction commit
Christian Reis
kiko at async.com.br
Mon Oct 6 12:38:31 EDT 2003
On Mon, Oct 06, 2003 at 11:46:33AM -0400, Shane Hathaway wrote:
> Steve Alexander wrote:
> >I'd like a way of saying to a data manager (_p_jar) that I intend to add
> >an object to the database, so the data manager can provide that object
> >with a suitable _p_jar and _p_oid. The oid would remain as set if the
> >object is attached to the database's root object (possibly via other
> >objects), and a transaction comimtted.
>
> FWIW, here is the way we do this in ZODB 3:
>
> f._p_jar = root_object._p_jar
> get_transaction().commit(1)
>
> The object "f" receives a _p_oid during subtransaction commit. A
> documented API would be better.
Problem is, you might not *want* to commit(1) the transaction -- you may
have checkpointed your transaction with a previous commit(1) and you
don't want to lose that as a sideeffect of setting a _p_oid to a new
object.
Maybe I should bring up a discussion of multiple commit(n) checkpoints
now? :-)
Take care,
--
Christian Reis | http://async.com.br/~kiko/ | [+55 16] 261 2331
More information about the ZODB-Dev
mailing list