[Zodb-checkins] SVN: ZODB/branches/3.8/src/ZODB/ Added a __del__ to
fsIndex.
Jim Fulton
jim at zope.com
Mon May 12 18:42:39 EDT 2008
Log message for revision 86677:
Added a __del__ to fsIndex.
Changed:
U ZODB/branches/3.8/src/ZODB/fsIndex.py
U ZODB/branches/3.8/src/ZODB/tests/testfsIndex.py
-=-
Modified: ZODB/branches/3.8/src/ZODB/fsIndex.py
===================================================================
--- ZODB/branches/3.8/src/ZODB/fsIndex.py 2008-05-12 22:41:58 UTC (rev 86676)
+++ ZODB/branches/3.8/src/ZODB/fsIndex.py 2008-05-12 22:42:39 UTC (rev 86677)
@@ -83,6 +83,15 @@
self._data[treekey] = tree
tree[key[6:]] = value
+ def __delitem__(self, key):
+ treekey = key[:6]
+ tree = self._data.get(treekey)
+ if tree is None:
+ raise KeyError, key
+ del tree[key[6:]]
+ if not tree:
+ del self._data[treekey]
+
def __len__(self):
r = 0
for tree in self._data.itervalues():
Modified: ZODB/branches/3.8/src/ZODB/tests/testfsIndex.py
===================================================================
--- ZODB/branches/3.8/src/ZODB/tests/testfsIndex.py 2008-05-12 22:41:58 UTC (rev 86676)
+++ ZODB/branches/3.8/src/ZODB/tests/testfsIndex.py 2008-05-12 22:42:39 UTC (rev 86677)
@@ -26,6 +26,24 @@
for i in range(200):
self.index[p64(i * 1000)] = (i * 1000L + 1)
+ def test__del__(self):
+ index = self.index
+ self.assert_(p64(1000) in index)
+ self.assert_(p64(100*1000) in index)
+
+ del self.index[p64(1000)]
+ del self.index[p64(100*1000)]
+
+ self.assert_(p64(1000) not in index)
+ self.assert_(p64(100*1000) not in index)
+
+ for key in list(self.index):
+ del index[key]
+ self.assert_(not index)
+
+ # Whitebox. Make sure empty buckets are removed
+ self.assert_(not index._data)
+
def testInserts(self):
index = self.index
More information about the Zodb-checkins
mailing list