Commit 40218cda authored by Boris Kocherov's avatar Boris Kocherov

ActionTool: add clearGetActionListCache after migration and use cacheable getActionList

parent 6e48b97e
...@@ -67,8 +67,10 @@ class ActionsTool(BaseTool, ActionProviderBase, CMFCore_ActionsTool): ...@@ -67,8 +67,10 @@ class ActionsTool(BaseTool, ActionProviderBase, CMFCore_ActionsTool):
getattr(provider, 'listActionInfos', None) is None ): getattr(provider, 'listActionInfos', None) is None ):
logger.info('migrating actions from %r to %r', logger.info('migrating actions from %r to %r',
portal_actions_path, '/'.join(provider.getPhysicalPath())) portal_actions_path, '/'.join(provider.getPhysicalPath()))
if provider._actions:
for old_action in provider._actions: for old_action in provider._actions:
self._importOldAction(old_action) self._importOldAction(old_action)
self.clearGetActionListCache()
del provider._actions del provider._actions
if (getattr(provider, 'listActionInfos', None) is None and if (getattr(provider, 'listActionInfos', None) is None and
getattr(provider, 'getActionListFor', None) is None and getattr(provider, 'getActionListFor', None) is None and
...@@ -76,9 +78,10 @@ class ActionsTool(BaseTool, ActionProviderBase, CMFCore_ActionsTool): ...@@ -76,9 +78,10 @@ class ActionsTool(BaseTool, ActionProviderBase, CMFCore_ActionsTool):
action_providers.remove(provider_name) action_providers.remove(provider_name)
self.action_providers = tuple(action_providers) self.action_providers = tuple(action_providers)
security.declarePrivate('getActionListFor') security.declareProtected(Permissions.AccessContentsInformation,
def getActionListFor(self, ob=None): 'getActionInformationList')
"""Return all actions applicable to the object""" def getActionInformationList(self):
"""Return all Action Information objects stored on this portal type"""
old_actions = self._actions or () old_actions = self._actions or ()
if old_actions: if old_actions:
LOG('OldActionsTool', WARNING, "Converting portal_actions...") LOG('OldActionsTool', WARNING, "Converting portal_actions...")
...@@ -87,8 +90,15 @@ class ActionsTool(BaseTool, ActionProviderBase, CMFCore_ActionsTool): ...@@ -87,8 +90,15 @@ class ActionsTool(BaseTool, ActionProviderBase, CMFCore_ActionsTool):
self._importOldAction(action_info) self._importOldAction(action_info)
LOG('OldActionsTool', WARNING, "... portal_actions converted.") LOG('OldActionsTool', WARNING, "... portal_actions converted.")
self._actions = () self._actions = ()
self.clearGetActionListCache()
return ActionProviderBase.getActionInformationList(self)
security.declarePrivate('getActionListFor')
def getActionListFor(self, ob=None):
"""Return all actions applicable to the object"""
if ob is not None: if ob is not None:
return (action.getCacheableAction() for action in self.objectValues()) return self.getActionList()
return () return ()
def listFilteredActionsFor(self, object=None): def listFilteredActionsFor(self, object=None):
......
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