Commit 44562abd authored by Jens Vagelpohl's avatar Jens Vagelpohl

- LP #143639: When the last cache manager in a container is

  deleted, we need to remove all traces of it from the
  container.
parent 1bdd733c
......@@ -11,6 +11,10 @@ http://docs.zope.org/zope2/releases/.
Bugs Fixed
++++++++++
- LP #143639: When the last cache manager in a container is
deleted, we need to remove all traces of it from the
container.
- LP #143619: Make sure to remove a RAMCache's contents when the
ZODB object is removed.
......
......@@ -442,8 +442,11 @@ class CacheManager:
ids = getVerifiedManagerIds(container)
id = self.getId()
if id in ids:
setattr(container, ZCM_MANAGERS, filter(
lambda s, id=id: s != id, ids))
manager_ids = filter(lambda s, id=id: s != id, ids)
if manager_ids:
setattr(container, ZCM_MANAGERS, manager_ids)
elif getattr(aq_base(self), ZCM_MANAGERS, None) is not None:
delattr(self, ZCM_MANAGERS)
global manager_timestamp
manager_timestamp = time.time()
......
import unittest
from OFS.Cache import CacheManager
from OFS.Folder import Folder
from OFS.SimpleItem import SimpleItem
from Products.Five.eventconfigure import setDeprecatedManageAddDelete
class DummyCacheManager(CacheManager, SimpleItem):
def __init__(self, id, *args, **kw):
self.id = id
setDeprecatedManageAddDelete(DummyCacheManager)
class CacheTests(unittest.TestCase):
def test_managersExist(self):
from OFS.Cache import managersExist
from OFS.DTMLMethod import DTMLMethod
root = Folder('root')
root._setObject('root_cache' , DummyCacheManager('root_cache'))
root._setObject('child', Folder('child'))
root.child._setObject('child_cache', DummyCacheManager('child_cache'))
root.child._setObject('child_content', DTMLMethod('child_content'))
# To begin with, cache managers will be found correctly
# using managersExist
self.failUnless(managersExist(root.child.child_content))
# Now we delete the cache in the child folder
root.child.manage_delObjects(['child_cache'])
# The parent_cache should still trigger managersExist
self.failUnless(managersExist(root.child.child_content))
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(CacheTests))
return suite
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