Log message for revision 113567: - LP #143639: When the last cache manager in a container is deleted, we need to remove all traces of it from the container.
Changed: U Zope/branches/2.12/doc/CHANGES.rst U Zope/branches/2.12/src/OFS/Cache.py A Zope/branches/2.12/src/OFS/tests/testCache.py -=- Modified: Zope/branches/2.12/doc/CHANGES.rst =================================================================== --- Zope/branches/2.12/doc/CHANGES.rst 2010-06-16 16:38:54 UTC (rev 113566) +++ Zope/branches/2.12/doc/CHANGES.rst 2010-06-16 17:32:10 UTC (rev 113567) @@ -11,6 +11,10 @@ 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. Modified: Zope/branches/2.12/src/OFS/Cache.py =================================================================== --- Zope/branches/2.12/src/OFS/Cache.py 2010-06-16 16:38:54 UTC (rev 113566) +++ Zope/branches/2.12/src/OFS/Cache.py 2010-06-16 17:32:10 UTC (rev 113567) @@ -442,8 +442,11 @@ 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() Added: Zope/branches/2.12/src/OFS/tests/testCache.py =================================================================== --- Zope/branches/2.12/src/OFS/tests/testCache.py (rev 0) +++ Zope/branches/2.12/src/OFS/tests/testCache.py 2010-06-16 17:32:10 UTC (rev 113567) @@ -0,0 +1,38 @@ +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 Property changes on: Zope/branches/2.12/src/OFS/tests/testCache.py ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org https://mail.zope.org/mailman/listinfo/zope-checkins