Commit 15b56f47 authored by Georgios Dagkakis's avatar Georgios Dagkakis

patches/ActionsTool: patch further listFilteredActionsFor to cleanup defined urls

from double slashes. This to give compatibility with definition
in actions on Web Section and Web Site portal types, for which now
absolute_url returns a trailing slash, so definitions like:

string:${object_url}/WebSection_xxx

would create a url with double slashes
parent 1a48ebbc
......@@ -21,6 +21,7 @@ from AccessControl import ClassSecurityInfo
from Products.CMFCore.ActionsTool import ActionsTool
from Products.CMFCore.interfaces import IActionProvider
from Products.CMFCore.permissions import ManagePortal
from urlparse import urlparse, urlunparse
security = ClassSecurityInfo()
......@@ -54,8 +55,11 @@ def listFilteredActionsFor(self, object=None):
this API should be moved to listActionInfos() of each tool so as not to
create duplicate code paths that are sources of bugs.
Finally, this patch detects tools that are no longer action providers and
Also, this patch detects tools that are no longer action providers and
invokes the migration of their actions to portal_actions
Finally, this patch normalised the url defined in actions, in the case they
have double slashes
"""
actions = []
......@@ -90,6 +94,16 @@ def listFilteredActionsFor(self, object=None):
for action in actions:
filtered_actions.setdefault(action['category'], []).append(action)
# normalised the url defined in actions, in the case they
# have double slashes
for category, action_list in filtered_actions.iteritems():
for action in action_list:
url = action.get('url')
if isinstance(url, str):
parsed_list = list(urlparse(url))
parsed_list[2] = parsed_list[2].replace('//', '/')
action['url'] = urlunparse(parsed_list)
return filtered_actions
ActionsTool.listFilteredActionsFor = listFilteredActionsFor
......
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