[Zope3-checkins] CVS: ZODB4/src/transaction - interfaces.py:1.4

Jeremy Hylton jeremy@zope.com
Thu, 6 Mar 2003 19:15:28 -0500


Update of /cvs-repository/ZODB4/src/transaction
In directory cvs.zope.org:/tmp/cvs-serv2990/transaction

Modified Files:
	interfaces.py 
Log Message:
Add AbortError and IllegalStateError, two specialized TransactionError
classes.


=== ZODB4/src/transaction/interfaces.py 1.3 => 1.4 ===
--- ZODB4/src/transaction/interfaces.py:1.3	Wed Mar  5 17:12:38 2003
+++ ZODB4/src/transaction/interfaces.py	Thu Mar  6 19:15:26 2003
@@ -22,6 +22,29 @@
     This transaction should be resubmitted.
     """
 
+class IllegalStateError(TransactionError):
+    """An operation was invoked that wasn't valid in the current
+    transaction state.
+    """
+
+    def __init__(self, verb, state):
+        self._verb = verb
+        self._state = state
+
+    def __str__(self):
+        return "Can't %s transaction in %s state" % (self._verb,
+                                                     self._state)
+
+class AbortError(TransactionError):
+    """Transaction commit failed and the application must abort."""
+
+    def __init__(self, datamgr):
+        self.datamgr = datamgr
+
+    def __str__(self):
+        str = self.__class__.__doc__ + " Failed data manager: %s"
+        return str % self.datamgr
+
 class RollbackError(TransactionError):
     """An error occurred rolling back a savepoint."""