Log message for revision 113563:
  - LP #143619: Make sure to remove a RAMCache's contents when the
    ZODB object is removed.
  

Changed:
  U   Zope/trunk/doc/CHANGES.rst
  U   
Zope/trunk/src/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
  U   Zope/trunk/src/Products/StandardCacheManagers/RAMCacheManager.py
  U   Zope/trunk/src/Products/StandardCacheManagers/configure.zcml
  U   Zope/trunk/src/Products/StandardCacheManagers/subscribers.py
  U   
Zope/trunk/src/Products/StandardCacheManagers/tests/test_CacheManagerLocation.py

-=-
Modified: Zope/trunk/doc/CHANGES.rst
===================================================================
--- Zope/trunk/doc/CHANGES.rst  2010-06-16 15:58:36 UTC (rev 113562)
+++ Zope/trunk/doc/CHANGES.rst  2010-06-16 16:00:58 UTC (rev 113563)
@@ -181,6 +181,9 @@
 Bugs Fixed
 ++++++++++
 
+- LP #143619: Make sure to remove a RAMCache's contents when the
+  ZODB object is removed.
+
 - LP #143403: Prevent accidental acquisition of objectValues during
   recursive ownership changes when the changed object has no
   objectValues method.

Modified: 
Zope/trunk/src/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
===================================================================
--- 
Zope/trunk/src/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py    
    2010-06-16 15:58:36 UTC (rev 113562)
+++ 
Zope/trunk/src/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py    
    2010-06-16 16:00:58 UTC (rev 113563)
@@ -172,6 +172,10 @@
         ' '
         return self.id
 
+    security.declarePrivate('_remove_data')
+    def _remove_data(self):
+        caches.pop(self.__cacheid)
+
     security.declarePrivate('_resetCacheId')
     def _resetCacheId(self):
         self.__cacheid = '%s_%f' % (id(self), time.time())

Modified: Zope/trunk/src/Products/StandardCacheManagers/RAMCacheManager.py
===================================================================
--- Zope/trunk/src/Products/StandardCacheManagers/RAMCacheManager.py    
2010-06-16 15:58:36 UTC (rev 113562)
+++ Zope/trunk/src/Products/StandardCacheManagers/RAMCacheManager.py    
2010-06-16 16:00:58 UTC (rev 113563)
@@ -380,6 +380,10 @@
         ' '
         return self.id
 
+    security.declarePrivate('_remove_data')
+    def _remove_data(self):
+        caches.pop(self.__cacheid)
+
     security.declarePrivate('_resetCacheId')
     def _resetCacheId(self):
         self.__cacheid = '%s_%f' % (id(self), time.time())

Modified: Zope/trunk/src/Products/StandardCacheManagers/configure.zcml
===================================================================
--- Zope/trunk/src/Products/StandardCacheManagers/configure.zcml        
2010-06-16 15:58:36 UTC (rev 113562)
+++ Zope/trunk/src/Products/StandardCacheManagers/configure.zcml        
2010-06-16 16:00:58 UTC (rev 113563)
@@ -6,8 +6,19 @@
     handler="Products.StandardCacheManagers.subscribers.cloned" />
 
   <subscriber
+    for="Products.StandardCacheManagers.RAMCacheManager.RAMCacheManager
+         zope.lifecycleevent.ObjectRemovedEvent"
+    handler="Products.StandardCacheManagers.subscribers.removed" />
+
+
+  <subscriber
     
for="Products.StandardCacheManagers.AcceleratedHTTPCacheManager.AcceleratedHTTPCacheManager
          OFS.interfaces.IObjectClonedEvent"
     handler="Products.StandardCacheManagers.subscribers.cloned" />
 
+ <subscriber
+    
for="Products.StandardCacheManagers.AcceleratedHTTPCacheManager.AcceleratedHTTPCacheManager
+         zope.lifecycleevent.ObjectRemovedEvent"
+    handler="Products.StandardCacheManagers.subscribers.removed" />
+
 </configure>

Modified: Zope/trunk/src/Products/StandardCacheManagers/subscribers.py
===================================================================
--- Zope/trunk/src/Products/StandardCacheManagers/subscribers.py        
2010-06-16 15:58:36 UTC (rev 113562)
+++ Zope/trunk/src/Products/StandardCacheManagers/subscribers.py        
2010-06-16 16:00:58 UTC (rev 113563)
@@ -22,3 +22,5 @@
     """ 
     obj._resetCacheId()
 
+def removed(obj, event):
+    obj._remove_data()

Modified: 
Zope/trunk/src/Products/StandardCacheManagers/tests/test_CacheManagerLocation.py
===================================================================
--- 
Zope/trunk/src/Products/StandardCacheManagers/tests/test_CacheManagerLocation.py
    2010-06-16 15:58:36 UTC (rev 113562)
+++ 
Zope/trunk/src/Products/StandardCacheManagers/tests/test_CacheManagerLocation.py
    2010-06-16 16:00:58 UTC (rev 113563)
@@ -112,7 +112,11 @@
         cache_moved = cachemanager_moved.ZCacheManager_getCache()
         self.assertEqual(cache, cache_moved)
 
-    # XXX test cache is removed if cachemanager is deleted to prevent leaks?
+    def test_cache_deleted_on_remove(self):
+        old_cache = self.cachemanager.ZCacheManager_getCache()
+        self.folder1.manage_delObjects(['cache'])
+        new_cache = self.cachemanager.ZCacheManager_getCache()
+        self.assertNotEqual(old_cache, new_cache)
 
 class AcceleratedHTTPCacheManagerLocationTests(CacheManagerLocationTests):
 

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

Reply via email to