[ZODB-Dev] Re: [Zope3-dev] Re: revise transaction API
Casey Duncan
casey at zope.com
Wed Mar 24 17:14:04 EST 2004
On Wed, 24 Mar 2004 23:55:48 +0000
Christian Theune <ct at gocept.com> wrote:
> Howdi,
>
> On Tue, 2004-03-16 at 20:37, Tim Peters wrote:
> > [Christian Robottom Reis, on
> > http://zope.org/Wikis/ZODB/ReviseTransactionAPI
> > ]
> > > I see this mentions savepoints for ZODB4. Can you tell me if you
> > > can roll back to any savepoint in a running transaction's history?
> >
> > Yes, that's the idea.
> >
> > > If so, it would be a solution to that last (subtrasaction) problem
> > > I posted about.
[..]
> if password != reference:
> query("begin; update .... ; commit;")
> return 0
> ...
>
> This "kind of works", except when there are conflicts (or other
> circumstances) that will make Zope rollback the transaction and retry.
>
> So my question is: Is there a "standard" idiom one would use to
> implement this, even if the data is not stored outside of the ZODB?
I would implement this by aborting the current transaction (as usual),
incrementing the persistent counter and then commiting this new
transaction immediately.
If the counter was a conflict-free object (like a BTree.Length), and it
was the only thing ever updated in the second transaction, there would
never be any conflicts.
Honestly though, this is probably best handled by logging to another
file/database altogether, sort of like what you did above, but without
tying the two together transactionally.
-Casey
More information about the ZODB-Dev
mailing list