Commit 7ba32a9d authored by Jason Madden's avatar Jason Madden

Fix traversal of the python picklecache ring when invalidating if the order...

Fix traversal of the python picklecache ring when invalidating if the order doesn't exactly match the ring
parent 690441d9
......@@ -122,7 +122,7 @@ class PickleCache(object):
# splice into new
self.ring.prev.next, node.prev = node, self.ring.prev
self.ring.prev, node.next = node, self.ring
def ringlen(self):
""" See IPickleCache.
"""
......@@ -257,5 +257,6 @@ class PickleCache(object):
if node.object is value:
node.prev.next, node.next.prev = node.next, node.prev
break
node = node.next
elif oid in self.persistent_classes:
del self.persistent_classes[oid]
......@@ -661,6 +661,25 @@ class PickleCacheTests(unittest.TestCase):
self.assertEqual(c1._p_state, GHOST)
self.assertEqual(c2._p_state, GHOST)
def test_invalidate_hit_multiple_non_ghost(self):
from persistent.interfaces import UPTODATE
from persistent.interfaces import GHOST
from persistent._compat import _b
KEY = _b('123')
KEY2 = _b('456')
cache = self._makeOne()
c1 = self._makePersist(oid=KEY, jar=cache.jar, state=UPTODATE)
cache[KEY] = c1
c2 = self._makePersist(oid=KEY2, jar=cache.jar, state=UPTODATE)
cache[KEY2] = c2
self.assertEqual(cache.ringlen(), 2)
# These should be in the opposite order of how they were
# added to the ring to ensure ring traversal works
cache.invalidate([KEY2, KEY])
self.assertEqual(cache.ringlen(), 0)
self.assertEqual(c1._p_state, GHOST)
self.assertEqual(c2._p_state, GHOST)
def test_invalidate_hit_pclass(self):
from persistent._compat import _b
KEY = _b('123')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment