[ZODB-Dev] API for dooming a transaction for ZODB 3.3

Steve Alexander steve at z3u.com
Sat Jan 10 16:09:31 EST 2004


> The scoping issue does not relate to transaction but to
> module boundaries. Say, your request contains functions
> from two independent "modules". One of them uses dooming,
> the other expects that when its locally successful
> operation should fail for some non local reasons there must
> be a clear error indication (say some account management -- if the
> account transaction does not occur for any reason, you must
> learn about this). When dooming looks like success (which may
> be adequate in some contexts), it does not merge well in all
> applications.

Currently, such an application needs to raise an exception. The
application code assumes that the exception will reach Zope's publisher,
and that the publisher will treat receiving the exception as a cue to
abort the transaction and show the error page.

However, if the exception is caught before it reaches the publisher,
then inappropriate state may be committed, as the publisher will have no
reason to abort the transaction.

So, I think the doom API would be useful in your example. In your
example, the application should call get_transaction().doom(), and then
it should raise an exception. If the publisher gets the exception, then
the transaction will be aborted, and the error page shown. If the
exception is caught before it reaches the publisher, then the
transaction still cannot be committed. This is not *ideal*, for the
application, but it is vastly better than inadvertantly committing bad
state.

The doom API allows you to ensure that a transaction that should not be
committed will not be committed.


> A "ConflictError" usually leads to a retry. When sufficiently many
> retries fail, you get an error indication.
> 
> If you want to get this with "dooming", I do not have much objections.

One obvious idea for Zope would be to treat a ConflictErrorOfDoom (a
subclass of ConflictError) like a regular ConflictError on commit, but
just fail straight away, rather than retrying several times.

--
Steve Alexander




More information about the ZODB-Dev mailing list