dabo Commit
Revision 2172
Date: 2006-05-20 20:17:28 -0700 (Sat, 20 May 2006)
Author: ed
Changed:
U trunk/dabo/biz/dBizobj.py
Log:
Added rollback to failed delete() transactions. Tracker Issue #0158.
Diff:
Modified: trunk/dabo/biz/dBizobj.py
===================================================================
--- trunk/dabo/biz/dBizobj.py 2006-05-18 14:49:56 UTC (rev 2171)
+++ trunk/dabo/biz/dBizobj.py 2006-05-21 03:17:28 UTC (rev 2172)
@@ -427,32 +427,41 @@
if startTransaction:
cursor.beginTransaction()
- cursor.delete()
- if self.RowCount == 0:
- # Hook method for handling the deletion of the last
record in the cursor.
- self.onDeleteLastRecord()
- # Now cycle through any child bizobjs and fire their cancel()
methods. This will
- # ensure that any changed data they may have is reverted. They
are then requeried to
- # populate them with data for the current record in this bizobj.
- for child in self.__children:
- if self.deleteChildLogic == k.REFINTEG_CASCADE:
- child.deleteAll(startTransaction=False)
+ try:
+ cursor.delete()
+ if self.RowCount == 0:
+ # Hook method for handling the deletion of the
last record in the cursor.
+ self.onDeleteLastRecord()
+ # Now cycle through any child bizobjs and fire their
cancel() methods. This will
+ # ensure that any changed data they may have is
reverted. They are then requeried to
+ # populate them with data for the current record in
this bizobj.
+ for child in self.__children:
+ if self.deleteChildLogic == k.REFINTEG_CASCADE:
+ child.deleteAll(startTransaction=False)
+ else:
+ child.cancelAll()
+ child.requery()
+
+ if startTransaction:
+ cursor.commitTransaction()
+
+ # Some backends (Firebird particularly) need to be told
to write
+ # their changes even if no explicit transaction was
started.
+ cursor.flush()
+
+ self.afterPointerMove()
+ self.afterChange()
+ self.afterDelete()
+ except dException.DBQueryException, e:
+ if startTransaction:
+ cursor.rollbackTransaction()
else:
- child.cancelAll()
- child.requery()
+ raise dException.DBQueryException, e
+ except StandardError, e:
+ cursor.rollbackTransaction()
+ raise StandardError, e
- if startTransaction:
- cursor.commitTransaction()
-
- # Some backends (Firebird particularly) need to be told to
write
- # their changes even if no explicit transaction was started.
- cursor.flush()
-
- self.afterPointerMove()
- self.afterChange()
- self.afterDelete()
-
def deleteAll(self, startTransaction=False):
""" Delete all rows in the data set."""
while self.RowCount > 0:
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev