Commit 547fdec0 authored by Julien Muchembled's avatar Julien Muchembled

'action_expression' -> 'action'

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/portal_types@29257 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 98c0980b
......@@ -79,7 +79,7 @@ module_list_form_id = (\'%s_view%sList\' % (module_portal_type,\n
module_portal_type_value.newContent(portal_type=\'Action Information\',\n
reference="view",\n
title="View",\n
action_expression="string:${object_url}/%s" % module_list_form_id,\n
action="string:${object_url}/%s" % module_list_form_id,\n
action_type="object_list")\n
\n
# Create the skin folder if does not exist yet\n
......@@ -186,7 +186,7 @@ portal.portal_workflow.setChainForPortalTypes([object_portal_type_id],\n
object_portal_type_value.newContent(portal_type=\'Action Information\',\n
reference="view",\n
title="View",\n
action_expression="string:${object_url}/%s" % form_view_id,\n
action="string:${object_url}/%s" % form_view_id,\n
action_type="object_view")\n
\n
# Finally add the module to the site\n
......
......@@ -84,17 +84,17 @@ class ActionInformation(XMLObject):
return condition is None or condition(ec)
return False
security.declarePublic('getVisibility')
def getVisibility(self):
"""Return whether the action should be visible in the CMF UI"""
return self.isVisible()
security.declarePrivate('getActionUrl')
def getActionUrl(self, ec):
action = self.getAction()
return action is not None and action(ec) or ''
def _setActionExpression(self, value):
def _setAction(self, value):
"""Overridden setter for 'action' to accept strings and clean null values
"""
if isinstance(value, basestring):
value = value and Expression(value) or None
self._baseSetActionExpression(value)
self._baseSetAction(value)
def _setCondition(self, value):
"""Overridden setter for 'condition' to accept string and clean null values
"""
......@@ -108,6 +108,11 @@ class ActionInformation(XMLObject):
value = value and Expression(value) or None
self._baseSetIcon(value)
def getAction(self):
"""Overridden getter for 'action' to clean null values"""
if getattr(aq_base(self), 'action', None) == '':
del self.action
return self._baseGetAction()
def getCondition(self):
"""Overridden getter for 'condition' to clean null values"""
if getattr(aq_base(self), 'condition', None) == '':
......@@ -122,7 +127,7 @@ class ActionInformation(XMLObject):
security.declareProtected(AccessContentsInformation, 'getActionText')
def getActionText(self):
"""Return the text of the action expression"""
return getattr(self.getActionExpression(), 'text', None)
return getattr(self.getAction(), 'text', None)
security.declareProtected(AccessContentsInformation, 'getConditionText')
def getConditionText(self):
"""Return the text of the condition expression"""
......@@ -141,7 +146,3 @@ class ActionInformation(XMLObject):
self.getActionText(),
self.getConditionText()]
return ' '.join(filter(None, search_source_list))
security.declarePrivate('getActionUrl')
def getActionUrl(self, ec):
return self.getActionExpression()(ec)
......@@ -574,6 +574,7 @@ class ERP5TypeInformation(XMLObject,
v = v.__class__(v.text)
setattr(action, {'id': 'reference',
'priority': 'float_index',
'permissions': 'action_permission',
}.get(k, k), v)
action.uid = None
action = self[self._setObject(action.id, action, set_owner=0)]
......@@ -585,13 +586,12 @@ class ERP5TypeInformation(XMLObject,
from Products.CMFCore.ActionInformation import ActionInformation
old_action = ActionInformation(action.reference,
category=action.getActionType(),
# We don't have the same default values for the following properties:
priority=action.getFloatIndex(),
permissions=tuple(action.getActionPermissionList()))
for k, v in action.__dict__.iteritems():
if k in ('action', 'condition', 'icon'):
v = v.__class__(v.text)
elif k in ('id', 'float_index', 'permissions', 'reference'):
elif k in ('id', 'float_index', 'action_permission', 'reference'):
continue
setattr(old_action, k, v)
return old_action
......
......@@ -44,7 +44,6 @@ class ActionInformation:
'mode': 'w',
},
{ 'id': 'action_permission',
'storage_id': 'permissions', # CMF Compatibility
'type': 'lines',
'description': 'The permissions required to use the action',
'mode': 'w',
......@@ -62,8 +61,7 @@ class ActionInformation:
'mode': 'w',
'default': True,
},
{ 'id': 'action_expression', # CMF Compatibility
'storage_id': 'action',
{ 'id': 'action',
'type': 'object',
'description': 'TALES Expression to define the URL of the action',
'mode': 'w',
......
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