Re: Re: SVN: Zope/trunk/lib/python/Testing/ZopeTestCase/ transaction.commit(1) is deprecated in favor of transaction.savepoint().
Tim Peters <[email protected]> Thu, 3 Nov 2005 10:22:39 -0500
| Newsgroups | gmane.comp.web.zope.coders |
|---|---|
| Message-ID | <[email protected]> |
>>> Log message for revision 39807:
>>> transaction.commit(1) is deprecated in favor of transaction.savepoint=
().
[Tres Seaver]
>> This likely needs to be 'savepoint(optimistic=3DTrue)' (see collector
>> #1860 for rationale).
[Stefan H. Holek]
> Perhaps. However, these tests specifically check interactions between
> persistent objects, their attributes, and transaction commit/abort.
> If things break there, I want to know about it.
The full deprecation msg spells it out in more detail:
subtransactions are deprecated; instead of transaction.commit(1), use
transaction.savepoint(optimistic=3DTrue) in contexts where a subtransac=
tion
abort will never occur, or sp=3Dtransaction.savepoint() if later rollba=
ck is
possible and then sp.rollback() instead of transaction.abort(1)
If you're not testing *sub*transaction aborts (you only mention
"transaction abort" above, and that's not the same thing), then
there's no reason to avoid passing optimistic=3DTrue.
The only effect _not_ passing True has then is to raise a nuisance
exception if some data manager involved in the transaction doesn't
support the new ISavepoint interface. But if you're never going to do
a subtransaction abort, then there's no need for any data manager to
support ISavepoint. That's why optimistic=3D exists. If you _are_
going to do a subtransaction abort, then just calling
"transaction.savepoint()" is inadequate: you would need also to
assign the result of that to a variable, in order to call its
rollback) method later (at the point where you used to do
transaction.abort(1)).
So, either way, the current code is a bit off target. Best guess is
that you're not interested in *sub*transaction aborts here, so that
you do want to pass optimistic=3DTrue.