Commit d0bda30c authored by Jeremy Hylton's avatar Jeremy Hylton

Reformat some methods for readability.

(Minor change to tb handling to avoid unnecessary binding to None for
v and tb.)
parent fca2086f
...@@ -84,8 +84,8 @@ ...@@ -84,8 +84,8 @@
############################################################################## ##############################################################################
"""Transaction management """Transaction management
$Id: Transaction.py,v 1.30 2001/06/04 18:25:38 andreas Exp $""" $Id: Transaction.py,v 1.31 2001/10/22 20:08:33 jeremy Exp $"""
__version__='$Revision: 1.30 $'[11:-2] __version__='$Revision: 1.31 $'[11:-2]
import time, sys, struct, POSException import time, sys, struct, POSException
from struct import pack from struct import pack
...@@ -150,9 +150,9 @@ class Transaction: ...@@ -150,9 +150,9 @@ class Transaction:
data manager doesn't support partial abort. data manager doesn't support partial abort.
""") """)
t=v=tb=None t = None
subj=self._sub subj = self._sub
subjars=() subjars = ()
if not subtransaction: if not subtransaction:
...@@ -160,40 +160,43 @@ class Transaction: ...@@ -160,40 +160,43 @@ class Transaction:
# may have been stowed away from previous subtransaction # may have been stowed away from previous subtransaction
# commits. # commits.
if self._non_st_objects is not None: if self._non_st_objects is not None:
append=self._objects.append self._objects.extend(self._non_st_objects)
for object in self._non_st_objects:
append(object)
self._non_st_objects = None self._non_st_objects = None
if subj is not None: if subj is not None:
# Abort of top-level transaction after commiting # Abort of top-level transaction after commiting
# subtransactions. # subtransactions.
subjars=subj.values() subjars = subj.values()
self._sub=None self._sub = None
try: try:
# Abort the objects # Abort the objects
for o in self._objects: for o in self._objects:
try: try:
j=getattr(o, '_p_jar', o) j = getattr(o, '_p_jar', o)
if j is not None: j.abort(o, self) if j is not None:
j.abort(o, self)
except: except:
if t is None: if t is None:
t,v,tb=sys.exc_info() t, v, tb = sys.exc_info()
# Ugh, we need to abort work done in sub-transactions. # Ugh, we need to abort work done in sub-transactions.
while subjars: while subjars:
j=subjars.pop() j = subjars.pop()
j.abort_sub(self) # This should never fail j.abort_sub(self) # This should never fail
if t is not None: raise t,v,tb if t is not None:
raise t, v, tb
finally: finally:
tb=None if t is not None:
del tb # don't keep traceback in local variable
del self._objects[:] # Clear registered del self._objects[:] # Clear registered
if not subtransaction and freeme: if not subtransaction and freeme:
if self._id is not None: free_transaction() if self._id is not None:
else: self._init() free_transaction()
else:
self._init()
def begin(self, info=None, subtransaction=None): def begin(self, info=None, subtransaction=None):
'''Begin a new transaction. '''Begin a new transaction.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment