[Erp5-report] r44065 nicolas - /erp5/trunk/products/ERP5Type/patches/
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Mar 9 10:02:28 CET 2011
Author: nicolas
Date: Wed Mar 9 10:02:27 2011
New Revision: 44065
URL: http://svn.erp5.org?rev=44065&view=rev
Log:
Since CMF2.2 cataloged variables support TALES Expression as well in worklists.
This patch add support of this feature and allows to use more dynamic and more configurable
Worklists.
Modified:
erp5/trunk/products/ERP5Type/patches/DCWorkflow.py
erp5/trunk/products/ERP5Type/patches/WorkflowTool.py
Modified: erp5/trunk/products/ERP5Type/patches/DCWorkflow.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/patches/DCWorkflow.py?rev=44065&r1=44064&r2=44065&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/patches/DCWorkflow.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/patches/DCWorkflow.py [utf8] Wed Mar 9 10:02:27 2011
@@ -152,10 +152,14 @@ def DCWorkflowDefinition_listGlobalActio
var_match_keys = qdef.getVarMatchKeys()
if var_match_keys:
# Check the catalog for items in the worklist.
- catalog = getToolByName(self, 'portal_catalog')
+ catalog = portal.portal_catalog
for k in var_match_keys:
v = qdef.getVarMatch(k)
- v_fmt = map(lambda x, info=info: x%info, v)
+ if instance(v, Expression):
+ v_fmt = v(createExprContext(StateChangeInfo(portal,
+ self, kwargs=info.__dict__.copy())))
+ else:
+ v_fmt = map(lambda x, info=info: x%info, v)
dict[k] = v_fmt
# Patch to automatically filter workflists per portal type
# so that the same state can be used for different
@@ -205,6 +209,8 @@ def DCWorkflowDefinition_listGlobalActio
DCWorkflowDefinition.listGlobalActions = DCWorkflowDefinition_listGlobalActions
+from Products.DCWorkflow.Expression import Expression
+
from Products.ERP5Type.patches.WorkflowTool import SECURITY_PARAMETER_ID, WORKLIST_METADATA_KEY
def DCWorkflowDefinition_getWorklistVariableMatchDict(self, info,
check_guard=True):
@@ -241,7 +247,17 @@ def DCWorkflowDefinition_getWorklistVari
action_box_name = worklist_definition.actbox_name
guard = worklist_definition.guard
if action_box_name:
- variable_match = dict(((x, [y % info for y in worklist_definition.getVarMatch(x)]) for x in worklist_definition.getVarMatchKeys()))
+ variable_match = {}
+ for key in worklist_definition.getVarMatchKeys():
+ var = worklist_definition.getVarMatch(key)
+ if isinstance(var, Expression):
+ evaluated_value = var(createExprContext(StateChangeInfo(portal,
+ self, kwargs=info.__dict__.copy())))
+ if isinstance(evaluated_value, (str, int, long)):
+ evaluated_value = [str(evaluated_value)]
+ else:
+ evaluated_value = [x % info for x in var]
+ variable_match[key] = evaluated_value
if 'portal_type' in variable_match and len(variable_match['portal_type']):
portal_type_intersection = set(variable_match['portal_type'])\
.intersection(portal_type_list)
@@ -264,8 +280,9 @@ def DCWorkflowDefinition_getWorklistVari
if is_permitted_worklist:
format_data = TemplateDict()
format_data._push(info)
- format_data._push({'portal_type': '&portal_type='.join(variable_match['portal_type']),
- 'local_roles': '&local_roles='.join(variable_match.get(SECURITY_PARAMETER_ID, []))})
+ variable_match.setdefault(SECURITY_PARAMETER_ID, ())
+ format_data._push(dict((k, ('&%s:list=' % k).join(v)) for\
+ k, v in variable_match.iteritems()))
variable_match[WORKLIST_METADATA_KEY] = {'format_data': format_data,
'worklist_title': action_box_name,
'worklist_id': worklist_id,
Modified: erp5/trunk/products/ERP5Type/patches/WorkflowTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/patches/WorkflowTool.py?rev=44065&r1=44064&r2=44065&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/patches/WorkflowTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/patches/WorkflowTool.py [utf8] Wed Mar 9 10:02:27 2011
@@ -119,6 +119,8 @@ def getValidCriterionDict(worklist_match
if isValidColumn(criterion_id):
if isinstance(criterion_value, tuple):
criterion_value = list(criterion_value)
+ elif isinstance(criterion_value, (str, int, long)):
+ criterion_value = [criterion_value]
assert criterion_id not in valid_criterion_dict
valid_criterion_dict[criterion_id] = criterion_value
elif criterion_id == WORKLIST_METADATA_KEY:
More information about the Erp5-report
mailing list