SVN: ZODB/trunk/src/BTrees/ Call readCurrent for internal nodes when making updates.

Jim Fulton <[email protected]>
Newsgroups gmane.comp.python.zope.zodb.cvs
Message-ID <[email protected]>
Log message for revision 116139:
  Call readCurrent for internal nodes when making updates.
  

Changed:
  U   ZODB/trunk/src/BTrees/BTreeTemplate.c
  U   ZODB/trunk/src/BTrees/tests/testBTrees.py

-=-
Modified: ZODB/trunk/src/BTrees/BTreeTemplate.c
===================================================================
--- ZODB/trunk/src/BTrees/BTreeTemplate.c	2010-09-02 13:55:38 UTC (rev 116138)
+++ ZODB/trunk/src/BTrees/BTreeTemplate.c	2010-09-02 13:55:40 UTC (rev 116139)
@@ -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/trunk/src/BTrees/tests/testBTrees.py
===================================================================
--- ZODB/trunk/src/BTrees/tests/testBTrees.py	2010-09-02 13:55:38 UTC (rev 116138)
+++ ZODB/trunk/src/BTrees/tests/testBTrees.py	2010-09-02 13:55:40 UTC (rev 116139)
@@ -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) """
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.