[Zope-CVS] CVS: Products/Ape/lib/apelib/zodb3 - storage.py:1.10.2.3

Shane Hathaway shane at zope.com
Fri Feb 27 11:21:14 EST 2004


Update of /cvs-repository/Products/Ape/lib/apelib/zodb3
In directory cvs.zope.org:/tmp/cvs-serv17406/lib/apelib/zodb3

Modified Files:
      Tag: ape-fs-oid-branch
	storage.py 
Log Message:
In debug mode, show the original hashes to make it easier to find mismatches.


=== Products/Ape/lib/apelib/zodb3/storage.py 1.10.2.2 => 1.10.2.3 ===
--- Products/Ape/lib/apelib/zodb3/storage.py:1.10.2.2	Thu Feb 26 11:32:30 2004
+++ Products/Ape/lib/apelib/zodb3/storage.py	Fri Feb 27 11:21:14 2004
@@ -53,6 +53,8 @@
         self._ltid = None
         self.scanner = None
         self.changed = {}  # {tid: {oid: 1}}
+        if DEBUG:
+            self._loaded_hashes = {}  # {oid: hash}
         BaseStorage.BaseStorage.__init__(self, name)
 
     def __len__(self):
@@ -79,8 +81,6 @@
         if h == HASH0:
             # Avoid the special zero hash.
             h = HASH1
-        if DEBUG:
-            print '64-bit hash of %r is %r' % (value, h)
         return h
 
     def load(self, oid, version):
@@ -97,7 +97,7 @@
             data = file.getvalue()
             h = self.hash64(hash_value)
             if DEBUG:
-                print 'loaded', `oid`, `h`
+                self._loaded_hashes[oid] = hash_value
             if self.scanner is not None:
                 sources = event.mapper.gateway.getPollSources(event)
                 self.scanner.afterLoad(oid, sources)
@@ -119,8 +119,6 @@
             # First detect conflicts.
             # The "h64" argument, if its value is not 0,
             # was previously generated by hash64().
-            if DEBUG:
-                print 'storing', `oid`, `h64`
             if h64 == HASH0:
                 # Writing a new object.
                 is_new = True
@@ -131,9 +129,15 @@
                 event, old_c, old_state, old_hash = self._gwio.load(oid)
                 old_h64 = self.hash64(old_hash)
                 if h64 != old_h64:
+                    h = None
+                    if DEBUG:
+                        h = self._loaded_hashes.get(oid)
+                    if h is None:
+                        h = h64
+                        old_hash = old_h64
                     raise POSException.ConflictError(
                         "Storing %s based on old data.  %s != %s." % (
-                        repr(oid), repr(h64), repr(old_h64)))
+                        repr(oid), repr(h), repr(old_hash)))
 
             # Now unpickle and store the data.
             file = StringIO(data)
@@ -153,8 +157,6 @@
         finally:
             self._lock_release()
 
-        if DEBUG:
-            print 'stored', `oid`, `h64`, `new_h64`
         return new_h64
 
     def getPollSources(self, oid):




More information about the Zope-CVS mailing list