Commit f983b270 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.
parents ef638278 44562abd
...@@ -181,6 +181,10 @@ Features Added ...@@ -181,6 +181,10 @@ Features Added
Bugs Fixed 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 - LP #143619: Make sure to remove a RAMCache's contents when the
ZODB object is removed. ZODB object is removed.
......
...@@ -442,8 +442,11 @@ class CacheManager: ...@@ -442,8 +442,11 @@ class CacheManager:
ids = getVerifiedManagerIds(container) ids = getVerifiedManagerIds(container)
id = self.getId() id = self.getId()
if id in ids: if id in ids:
setattr(container, ZCM_MANAGERS, filter( manager_ids = filter(lambda s, id=id: s != id, ids)
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 global manager_timestamp
manager_timestamp = time.time() 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