Commit 5025e7a3 authored by Jérome Perrin's avatar Jérome Perrin

make clearAllCache and clearCacheFactory public, but without docstring to

prevent calling them from the URL.
add manage_clearCacheFactory and manage_clearAllCache methods for the ZMI


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19484 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8e34c84f
...@@ -187,15 +187,38 @@ class CacheTool(BaseTool): ...@@ -187,15 +187,38 @@ class CacheTool(BaseTool):
if REQUEST is not None: if REQUEST is not None:
self.REQUEST.RESPONSE.redirect('cache_tool_configure?manage_tabs_message=Cache updated.') self.REQUEST.RESPONSE.redirect('cache_tool_configure?manage_tabs_message=Cache updated.')
security.declareProtected(Permissions.ModifyPortalContent, 'clearAllCache') security.declarePublic('clearAllCache')
def clearAllCache(self, REQUEST=None): def clearAllCache(self):
""" Clear all cache factories. """ # Clear all cache factories. This method is public to be called from
# scripts, but without docstring to prevent calling it from the URL
ram_cache_root = self.getRamCacheRoot() ram_cache_root = self.getRamCacheRoot()
for cf_key in ram_cache_root.keys(): for cf_key in ram_cache_root.keys():
for cp in ram_cache_root[cf_key].getCachePluginList(): for cp in ram_cache_root[cf_key].getCachePluginList():
cp.clearCache() cp.clearCache()
security.declareProtected(Permissions.ManagePortal, 'manage_clearAllCache')
def manage_clearAllCache(self, REQUEST=None):
"""Clear all cache factories."""
self.clearAllCache()
if REQUEST is not None: if REQUEST is not None:
self.REQUEST.RESPONSE.redirect('cache_tool_configure?manage_tabs_message=All cache factories cleared.') self.REQUEST.RESPONSE.redirect('cache_tool_configure?manage_tabs_message=All cache factories cleared.')
security.declarePublic('clearCacheFactory')
def clearCacheFactory(self, cache_factory_id):
# Clear cache factory of given ID.
# This method is public to be called from scripts, but without docstring to
# prevent calling it from the URL
ram_cache_root = self.getRamCacheRoot()
if ram_cache_root.has_key(cache_factory_id):
ram_cache_root[cache_factory_id].clearCache()
security.declareProtected(Permissions.ManagePortal, 'manage_clearCacheFactory')
def manage_clearCacheFactory(self, cache_factory_id, REQUEST=None):
""" Clear only cache factory. """
self.clearCacheFactory(cache_factory_id)
if REQUEST is not None:
self.REQUEST.RESPONSE.redirect('cache_tool_configure?manage_tabs_message=Cache factory %s cleared.' %cache_factory_id)
security.declareProtected(Permissions.ModifyPortalContent, 'clearCache') security.declareProtected(Permissions.ModifyPortalContent, 'clearCache')
def clearCache(self, cache_factory_list=(DEFAULT_CACHE_FACTORY,), REQUEST=None): def clearCache(self, cache_factory_list=(DEFAULT_CACHE_FACTORY,), REQUEST=None):
...@@ -208,15 +231,6 @@ class CacheTool(BaseTool): ...@@ -208,15 +231,6 @@ class CacheTool(BaseTool):
if REQUEST is not None: if REQUEST is not None:
self.REQUEST.RESPONSE.redirect('cache_tool_configure?manage_tabs_message=Cache cleared.') self.REQUEST.RESPONSE.redirect('cache_tool_configure?manage_tabs_message=Cache cleared.')
security.declareProtected(Permissions.ModifyPortalContent, 'clearCacheFactory')
def clearCacheFactory(self, cache_factory_id, REQUEST=None):
""" Clear only cache factory. """
ram_cache_root = self.getRamCacheRoot()
if ram_cache_root.has_key(cache_factory_id):
ram_cache_root[cache_factory_id].clearCache()
if REQUEST is not None:
self.REQUEST.RESPONSE.redirect('cache_tool_configure?manage_tabs_message=Cache factory %s cleared.' %cache_factory_id)
security.declareProtected(Permissions.ModifyPortalContent, 'clearCacheFactoryScope') security.declareProtected(Permissions.ModifyPortalContent, 'clearCacheFactoryScope')
def clearCacheFactoryScope(self, cache_factory_id, scope, REQUEST=None): def clearCacheFactoryScope(self, cache_factory_id, scope, REQUEST=None):
""" Clear only cache factory. """ """ Clear only cache factory. """
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
<dtml-var manage_tabs> <dtml-var manage_tabs>
<h3>Cache invalidation</h3> <h3>Cache invalidation</h3>
<form action="clearAllCache" method="POST"> <form action="manage_clearAllCache" method="POST">
<input type="submit" value="Clear all cache factories"/> <input type="submit" value="Clear all cache factories"/>
</form> </form>
<dtml-in expr="objectIds('ERP5 Cache Factory')"> <dtml-in expr="objectIds('ERP5 Cache Factory')">
<form action="clearCacheFactory" method="POST"> <form action="manage_clearCacheFactory" method="POST">
<input type="hidden" name="cache_factory_id" value="<dtml-var sequence-item>"> <input type="hidden" name="cache_factory_id" value="<dtml-var sequence-item>">
<input type="submit" value="Clear <dtml-var sequence-item>"/> <input type="submit" value="Clear <dtml-var sequence-item>"/>
</form> </form>
......
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