Log message for revision 113568:
  - 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/trunk/doc/CHANGES.rst
  U   Zope/trunk/src/OFS/Cache.py
  A   Zope/trunk/src/OFS/tests/testCache.py

-=-
Modified: Zope/trunk/doc/CHANGES.rst
===================================================================
--- Zope/trunk/doc/CHANGES.rst  2010-06-16 17:32:10 UTC (rev 113567)
+++ Zope/trunk/doc/CHANGES.rst  2010-06-16 17:34:33 UTC (rev 113568)
@@ -181,6 +181,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/trunk/src/OFS/Cache.py
===================================================================
--- Zope/trunk/src/OFS/Cache.py 2010-06-16 17:32:10 UTC (rev 113567)
+++ Zope/trunk/src/OFS/Cache.py 2010-06-16 17:34:33 UTC (rev 113568)
@@ -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()
 

Copied: Zope/trunk/src/OFS/tests/testCache.py (from rev 113567, 
Zope/branches/2.12/src/OFS/tests/testCache.py)
===================================================================
--- Zope/trunk/src/OFS/tests/testCache.py                               (rev 0)
+++ Zope/trunk/src/OFS/tests/testCache.py       2010-06-16 17:34:33 UTC (rev 
113568)
@@ -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

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
https://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to