As i see no meaning for interleaved transactions i can see no use of
using t1 and t2 (except to ensure destruction and thus rollback of
transactions when they go out of scope (or some time later))
Is'nt the same easily written like this using a Transaction object
with methods for keeping a stack of nested transactions
from transaction import *
Transaction = transaction(ThingThisTransactsOn)
try:
Transaction.Begin()
# some outer transaction code
try:
Transaction.Begin()
# do the sub-transaction stuff here
Transaction.Commit()
except (AnyButBeginOrCommitError):
Transaction.Rollback()
# some other cleanup
# some more outer transaction code
Transaction.Commit()
except (AnyButBeginOrCommitError):
Transaction.Rollback()
# some cleanup for failed outer transaction
# some non-transactional code (is there actually any? :)
aren't transactions just one kind of exception handling anyway?
perhaps we can make it into:
try(Transaction): # implies Transaction.Begin(), and
# Transaction.Commit() on success/no exception
#some transaction code
try(Transaction):
# do the sub-transaction stuff here
except (Any): # implies Transaction.Rollback() for inner trx
# some other cleanup
# some more outer transaction code
except ():
# some extra cleanup for failed outer transaction
# some non-transactional code (is there actually any? :)
Disclaimer: I am quite new to python,so i may be talking nonsense.
------------------------------
Hannu Krosing / hannu@estib.ee