[Zodb-checkins] SVN: ZODB/branches/jim-readCurrent/src/BTrees/ Call readCurrent for internal nodes when making updates.

Jim Fulton jim at zope.com
Wed Sep 1 18:03:52 EDT 2010


Log message for revision 116115:
  Call readCurrent for internal nodes when making updates.
  

Changed:
  U   ZODB/branches/jim-readCurrent/src/BTrees/BTreeTemplate.c
  U   ZODB/branches/jim-readCurrent/src/BTrees/tests/testBTrees.py

-=-
Modified: ZODB/branches/jim-readCurrent/src/BTrees/BTreeTemplate.c
===================================================================
--- ZODB/branches/jim-readCurrent/src/BTrees/BTreeTemplate.c	2010-09-01 22:03:50 UTC (rev 116114)
+++ ZODB/branches/jim-readCurrent/src/BTrees/BTreeTemplate.c	2010-09-01 22:03:52 UTC (rev 116115)
@@ -639,6 +639,10 @@
   BTREE_SEARCH(min, self, key, goto Error);
   d = self->data + min;
 
+#ifdef PERSISTENT
+  PER_READCURRENT(self, goto Error);
+#endif
+
   if (SameType_Check(self, d->child))
     status = _BTree_set(BTREE(d->child), keyarg, value, unique, noval);
   else {

Modified: ZODB/branches/jim-readCurrent/src/BTrees/tests/testBTrees.py
===================================================================
--- ZODB/branches/jim-readCurrent/src/BTrees/tests/testBTrees.py	2010-09-01 22:03:50 UTC (rev 116114)
+++ ZODB/branches/jim-readCurrent/src/BTrees/tests/testBTrees.py	2010-09-01 22:03:52 UTC (rev 116115)
@@ -146,6 +146,49 @@
         self.assertEqual(list(t.keys(0, 2, excludemin=True, excludemax=True)),
                          [1])
 
+    def testUpdatesDoReadChecksOnInternalNodes(self):
+        t = self.t
+        if not hasattr(t, '_firstbucket'):
+            return
+        self._populate(t, 1000)
+        store = MappingStorage()
+        db = DB(store)
+        conn = db.open()
+        conn.root.t = t
+        transaction.commit()
+
+        read = []
+        def readCurrent(ob):
+            read.append(ob)
+            conn.__class__.readCurrent(conn, ob)
+            return 1
+
+        conn.readCurrent = readCurrent
+
+        try:
+            add = t.add
+            remove = t.remove
+        except AttributeError:
+            def add(i):
+                t[i] = i
+            def remove(i):
+                del t[i]
+
+        # Modifying a thing
+        remove(100)
+        self.assert_(t in read)
+        del read[:]
+        add(100)
+        self.assert_(t in read)
+        del read[:]
+
+        transaction.abort()
+        conn.cacheMinimize()
+        # list(t)
+        # self.assert_(100 in t)
+        # self.assert_(not read)
+
+
 class MappingBase(Base):
     """ Tests common to mappings (buckets, btrees) """
 



More information about the Zodb-checkins mailing list