[Zodb-checkins] CVS: Zope3/src/zodb/storage - bdbfull.py:1.7 bdbminimal.py:1.5 file.py:1.5

Jeremy Hylton jeremy@zope.com
Wed, 15 Jan 2003 18:28:06 -0500


Update of /cvs-repository/Zope3/src/zodb/storage
In directory cvs.zope.org:/tmp/cvs-serv6701/zodb/storage

Modified Files:
	bdbfull.py bdbminimal.py file.py 
Log Message:
Simplify conflict error handling.

Rename tryToResolveConflict() to resolveConflict().

Change its contract to raise ConflictError on failure instead of
returning None.  This reduces the name of places that ConflictError
is raised but slightly complicates code that wants to raise UndoError
instead.


=== Zope3/src/zodb/storage/bdbfull.py 1.6 => 1.7 ===
--- Zope3/src/zodb/storage/bdbfull.py:1.6	Tue Dec 31 12:13:31 2002
+++ Zope3/src/zodb/storage/bdbfull.py	Wed Jan 15 18:28:02 2003
@@ -482,11 +482,8 @@
             # given in the call is not the same as the last stored serial
             # number.  First, attempt application level conflict
             # resolution, and if that fails, raise a ConflictError.
-            data = self.tryToResolveConflict(oid, oserial, serial, data)
-            if data:
-                conflictresolved = True
-            else:
-                raise interfaces.ConflictError(serials=(oserial, serial))
+            data = self.resolveConflict(oid, oserial, serial, data)
+            conflictresolved = True
         # Do we already know about this version?  If not, we need to record
         # the fact that a new version is being created.  version will be the
         # empty string when the transaction is storing on the non-version
@@ -1114,12 +1111,12 @@
             return oid, target_metadata, None
         else:
             # Attempt application level conflict resolution
-            data = self.tryToResolveConflict(
-                oid, ctid, tid, self._pickles[oid+target_lrevid])
-            if data:
-                return oid, target_metadata, data
-            else:
-                raise interfaces.UndoError, 'Cannot undo transaction'
+            try:
+                data = self.resolveConflict(
+                    oid, ctid, tid, self._pickles[oid+target_lrevid])
+            except interfaces.ConflictError:
+                raise interfaces.UndoError('Cannot undo transaction')
+            return oid, target_metadata, data
 
     def _dotxnundo(self, txn, tid):
         # First, make sure the transaction isn't protected by a pack.


=== Zope3/src/zodb/storage/bdbminimal.py 1.4 => 1.5 ===
--- Zope3/src/zodb/storage/bdbminimal.py:1.4	Tue Dec 31 12:12:27 2002
+++ Zope3/src/zodb/storage/bdbminimal.py	Wed Jan 15 18:28:03 2003
@@ -251,11 +251,8 @@
             # The object exists in the database, but the serial number
             # given in the call is not the same as the last stored serial
             # number.  Raise a ConflictError.
-            data = self.tryToResolveConflict(oid, oserial, serial, data)
-            if data:
-                conflictresolved = True
-            else:
-                raise interfaces.ConflictError(serials=(oserial, serial))
+            data = self.resolveConflict(oid, oserial, serial, data)
+            conflictresolved = True
         # Optimistically write to the serials and pickles table.  Be sure
         # to also update the oids table for this object too.
         newserial = self._serial


=== Zope3/src/zodb/storage/file.py 1.4 => 1.5 ===
--- Zope3/src/zodb/storage/file.py:1.4	Wed Jan 15 17:08:52 2003
+++ Zope3/src/zodb/storage/file.py	Wed Jan 15 18:28:03 2003
@@ -629,11 +629,8 @@
                     pnv = h.pnv
 
                 if serial != h.serial:
-                    data = self.tryToResolveConflict(oid, h.serial, serial,
+                    data = self.resolveConflict(oid, h.serial, serial,
                                                      data)
-                    if data is None:
-                        raise interfaces.ConflictError(oid=oid,
-                                                serials=(h.serial, serial))
 
             pos = self._pos
             here = pos + self._tfile.tell() + self._thl
@@ -1024,17 +1021,15 @@
             # couldn't find oid; what's the real explanation for this?
             raise UndoError(oid, "_loadBack() failed")
         try:
-            data = self.tryToResolveConflict(oid, cserial, serial, bdata,
-                                             cdata)
+            data = self.resolveConflict(oid, cserial, serial, bdata, cdata)
         except interfaces.ConflictError:
+            data = None
+
+        if data is None:
             raise UndoError(oid,
                             "Some data were modified by a later transaction")
-            
-
-        if data:
-            return data, 0, version, snv, ipos
+        return data, 0, version, snv, ipos
 
-        raise UndoError(oid, "Some data were modified by a later transaction")
 
     # undoLog() returns a description dict that includes an id entry.
     # The id is opaque to the client, but contains the transaction id.