Commit 1bdd733c authored by Jens Vagelpohl's avatar Jens Vagelpohl

- LP #143619: Make sure to remove a RAMCache's contents when the

  ZODB object is removed.
parent a08d51b3
...@@ -11,6 +11,9 @@ http://docs.zope.org/zope2/releases/. ...@@ -11,6 +11,9 @@ http://docs.zope.org/zope2/releases/.
Bugs Fixed 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 - LP #143403: Prevent accidental acquisition of objectValues during
recursive ownership changes when the changed object has no recursive ownership changes when the changed object has no
objectValues method. objectValues method.
......
...@@ -172,6 +172,10 @@ class AcceleratedHTTPCacheManager (CacheManager, SimpleItem): ...@@ -172,6 +172,10 @@ class AcceleratedHTTPCacheManager (CacheManager, SimpleItem):
' ' ' '
return self.id return self.id
security.declarePrivate('_remove_data')
def _remove_data(self):
caches.pop(self.__cacheid)
security.declarePrivate('_resetCacheId') security.declarePrivate('_resetCacheId')
def _resetCacheId(self): def _resetCacheId(self):
self.__cacheid = '%s_%f' % (id(self), time.time()) self.__cacheid = '%s_%f' % (id(self), time.time())
......
...@@ -380,6 +380,10 @@ class RAMCacheManager (CacheManager, SimpleItem): ...@@ -380,6 +380,10 @@ class RAMCacheManager (CacheManager, SimpleItem):
' ' ' '
return self.id return self.id
security.declarePrivate('_remove_data')
def _remove_data(self):
caches.pop(self.__cacheid)
security.declarePrivate('_resetCacheId') security.declarePrivate('_resetCacheId')
def _resetCacheId(self): def _resetCacheId(self):
self.__cacheid = '%s_%f' % (id(self), time.time()) self.__cacheid = '%s_%f' % (id(self), time.time())
......
...@@ -5,9 +5,20 @@ ...@@ -5,9 +5,20 @@
OFS.interfaces.IObjectClonedEvent" OFS.interfaces.IObjectClonedEvent"
handler="Products.StandardCacheManagers.subscribers.cloned" /> handler="Products.StandardCacheManagers.subscribers.cloned" />
<subscriber
for="Products.StandardCacheManagers.RAMCacheManager.RAMCacheManager
zope.lifecycleevent.ObjectRemovedEvent"
handler="Products.StandardCacheManagers.subscribers.removed" />
<subscriber <subscriber
for="Products.StandardCacheManagers.AcceleratedHTTPCacheManager.AcceleratedHTTPCacheManager for="Products.StandardCacheManagers.AcceleratedHTTPCacheManager.AcceleratedHTTPCacheManager
OFS.interfaces.IObjectClonedEvent" OFS.interfaces.IObjectClonedEvent"
handler="Products.StandardCacheManagers.subscribers.cloned" /> handler="Products.StandardCacheManagers.subscribers.cloned" />
<subscriber
for="Products.StandardCacheManagers.AcceleratedHTTPCacheManager.AcceleratedHTTPCacheManager
zope.lifecycleevent.ObjectRemovedEvent"
handler="Products.StandardCacheManagers.subscribers.removed" />
</configure> </configure>
...@@ -22,3 +22,5 @@ def cloned(obj, event): ...@@ -22,3 +22,5 @@ def cloned(obj, event):
""" """
obj._resetCacheId() obj._resetCacheId()
def removed(obj, event):
obj._remove_data()
...@@ -112,7 +112,11 @@ class CacheManagerLocationTests(CopySupportTestBase): ...@@ -112,7 +112,11 @@ class CacheManagerLocationTests(CopySupportTestBase):
cache_moved = cachemanager_moved.ZCacheManager_getCache() cache_moved = cachemanager_moved.ZCacheManager_getCache()
self.assertEqual(cache, cache_moved) 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): class AcceleratedHTTPCacheManagerLocationTests(CacheManagerLocationTests):
......
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