Commit 08c079bf authored by iv's avatar iv

ERP5Workflow: change default_expression to variable_expression for name consistency

parent b2c418cd
......@@ -148,7 +148,7 @@ class TestWorklist(testWorkflowMixin):
variable_value=worklist_variable_value,
reference=worklist_variable_key)
if isinstance(worklist_variable_value, str) and worklist_variable_value.startswith('python'):
worklist_variable.setDefaultExpression(worklist_variable_value)
worklist_variable.setVariableExpression(worklist_variable_value)
def createDCWorklist(self, workflow_value, worklist_id, actbox_name,
actbox_url=None, **kw):
......
......@@ -102,7 +102,7 @@
<string>Available for Catalog</string>
</tuple>
<tuple>
<string>default_expression</string>
<string>variable_expression</string>
<string>Expression</string>
</tuple>
</list>
......
......@@ -102,7 +102,7 @@
<string>Available for Catalog</string>
</tuple>
<tuple>
<string>default_expression</string>
<string>variable_expression</string>
<string>Expression</string>
</tuple>
</list>
......
......@@ -85,7 +85,7 @@
<list>
<string>my_causality</string>
<string>my_variable_value</string>
<string>my_default_expression</string>
<string>my_variable_expression</string>
</list>
</value>
</item>
......
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>my_default_expression</string> </value>
<value> <string>my_variable_expression</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......
......@@ -93,7 +93,7 @@
<string>my_for_status</string>
<string>my_automatic_update</string>
<string>my_variable_value</string>
<string>my_default_expression</string>
<string>my_variable_expression</string>
</list>
</value>
</item>
......
......@@ -16,7 +16,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_default_expression</string> </value>
<value> <string>my_variable_expression</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......
......@@ -60,29 +60,29 @@ context.setSourceValue(state)\n
for v, property_dict in (\n
(\'action\', {\n
\'description\': \'Transition id\',\n
\'default_expression\': \'transition/getReference|nothing\',\n
\'variable_expression\': \'transition/getReference|nothing\',\n
\'for_status\': 1,\n
\'automatic_update\': 1,\n
}),\n
(\'actor\', {\n
\'description\': \'Name of the user who performed transition\',\n
\'default_expression\': \'user/getUserName\',\n
\'variable_expression\': \'user/getUserName\',\n
\'for_status\': 1,\n
\'automatic_update\': 1,\n
}),\n
(\'comment\', {\n
\'description\': \'Comment about transition\',\n
\'default_expression\': "python:state_change.kwargs.get(\'comment\', \'\')",\n
\'variable_expression\': "python:state_change.kwargs.get(\'comment\', \'\')",\n
\'for_status\': 1,\n
\'automatic_update\': 1,\n
}),\n
(\'history\', {\n
\'description\': \'Provides access to workflow history\',\n
\'default_expression\': \'state_change/getHistory\',\n
\'variable_expression\': \'state_change/getHistory\',\n
}),\n
(\'time\', {\n
\'description\': \'Transition timestamp\',\n
\'default_expression\': \'state_change/getDateTime\',\n
\'variable_expression\': \'state_change/getDateTime\',\n
\'for_status\': 1,\n
\'automatic_update\': 1,\n
}),\n
......
......@@ -102,7 +102,7 @@
<string>Available for Catalog</string>
</tuple>
<tuple>
<string>default_expression</string>
<string>variable_expression</string>
<string>Expression</string>
</tuple>
</list>
......
......@@ -85,7 +85,7 @@
<list>
<string>my_reference</string>
<string>my_variable_value</string>
<string>my_default_expression</string>
<string>my_variable_expression</string>
</list>
</value>
</item>
......
......@@ -16,7 +16,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_default_expression</string> </value>
<value> <string>my_variable_expression</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......
......@@ -84,7 +84,7 @@
<string>Title</string>
</tuple>
<tuple>
<string>default_expression</string>
<string>variable_expression</string>
<string>Expression</string>
</tuple>
<tuple>
......
......@@ -22,7 +22,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>default_expression_property</string> </value>
<value> <string>variable_expression_property</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
......@@ -30,7 +30,7 @@
</item>
<item>
<key> <string>storage_id</string> </key>
<value> <string>default_expression</string> </value>
<value> <string>variable_expression</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -140,13 +140,13 @@ class InteractionWorkflow(IdAsReferenceMixin("", "prefix"), Workflow):
getSecurityManager(), self, ob):
return default
status = self._getStatusOf(ob)
default_expression = vdef.getDefaultExpression()
variable_expression = vdef.getVariableExpression()
if status is not None and name in status:
value = status[name]
# Not set yet. Use a default.
elif default_expression is not None:
elif variable_expression is not None:
ec = createExprContext(StateChangeInfo(ob, self, status))
value = Expression(default_expression)(ec)
value = Expression(variable_expression)(ec)
else:
value = vdef.getVariableValue()
......@@ -286,9 +286,9 @@ class InteractionWorkflow(IdAsReferenceMixin("", "prefix"), Workflow):
# Preserve former value
value = former_status[id]
else:
default_expression = vdef.getDefaultExpression()
if default_expression is not None:
expression = Expression(default_expression)
variable_expression = vdef.getVariableExpression()
if variable_expression is not None:
expression = Expression(variable_expression)
else:
value = vdef.getVariableValue()
if expression is not None:
......@@ -468,7 +468,7 @@ class InteractionWorkflow(IdAsReferenceMixin("", "prefix"), Workflow):
# 2. Variable as XML
variable_reference_list = []
variable_list = self.objectValues(portal_type='Variable')
variable_prop_id_to_show = ['description', 'default_expression',
variable_prop_id_to_show = ['description', 'variable_expression',
'for_catalog', 'for_status', 'update_always']
for vdef in variable_list:
variable_reference_list.append(vdef.getReference())
......
......@@ -49,7 +49,7 @@ class Variable(IdAsReferenceMixin("variable_", "prefix"), XMLObject):
for_catalog = 1
for_status = 1
variable_value = ''
default_expression = None # Overrides variable_value if set
variable_expression = None # Overrides variable_value if set
update_always = 1
default_reference = ''
# Declarative security
......
......@@ -430,14 +430,14 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
getSecurityManager(), self, ob):
return default
status = self.getCurrentStatusDict(ob)
default_expression = vdef.getDefaultExpression()
variable_expression = vdef.getVariableExpression()
if status is not None and status.has_key(name):
value = status[name]
# Not set yet. Use a default.
elif default_expression is not None:
elif variable_expression is not None:
ec = createExprContext(StateChangeInfo(ob, self, status))
value = Expression(default_expression)(ec)
value = Expression(variable_expression)(ec)
else:
value = vdef.getVariableValue()
......@@ -640,7 +640,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
if tdef is not None:
transition_variable_list = tdef.objectValues(portal_type='Transition Variable')
for transition_variable in transition_variable_list:
tdef_exprs[transition_variable.getCausalityId()] = transition_variable.getDefaultExpression()
tdef_exprs[transition_variable.getCausalityId()] = transition_variable.getVariableExpression()
# Update all transition variables
if form_kw is not None:
......@@ -661,8 +661,8 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
# Preserve former value
value = former_status[variable_reference]
else:
if vdef.getDefaultExpression() is not None:
expr = vdef.getDefaultExpression()
if vdef.getVariableExpression() is not None:
expr = vdef.getVariableExpression()
else:
value = vdef.getVariableValue(object=object)
if expr is not None and expr != '':
......@@ -888,7 +888,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
for tr_var in tr_var_list:
reference = self._getOb(tr_var.getCausalityId()).getReference()
transition_variable = SubElement(transition_variables, property_id, attrib=dict(id=reference,type='variable'))
transition_variable.text = str(tr_var.getDefaultExpression())
transition_variable.text = str(tr_var.getVariableExpression())
else:
property_value = tdef.getProperty(property_id)
property_type = tdef.getPropertyType(property_id)
......@@ -900,7 +900,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
# 3. Variable as XML
variable_reference_list = []
variable_list = self.objectValues(portal_type='Variable')
variable_prop_id_to_show = ['description', 'default_expression',
variable_prop_id_to_show = ['description', 'variable_expression',
'for_catalog', 'for_status', 'update_always']
for vdef in variable_list:
variable_reference_list.append(vdef.getReference())
......@@ -927,7 +927,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
sub_object.text = str(property_value)
# for a very specific case, action return the reference of transition,
# but in XML should show the same expression as in DC workflow.
if vdef.getId() == 'variable_action' and property_id == 'default_expression' and property_value != '':
if vdef.getId() == 'variable_action' and property_id == 'variable_expression' and property_value != '':
sub_object.text = str('transition/getId|nothing')
# 4. Worklist as XML
......@@ -1061,9 +1061,9 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
# Preserve former value
value = former_status[id]
else:
default_expression = vdef.getDefaultExpression()
if default_expression is not None:
expr = Expression(default_expression)
variable_expression = vdef.getVariableExpression()
if variable_expression is not None:
expr = Expression(variable_expression)
else:
value = vdef.getVariableValue()
if expr is not None:
......@@ -1113,15 +1113,15 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
status = self.getCurrentStatusDict(ob)
for vdef_ref, vdef in self.getVariableValueDict().iteritems():
if vdef.getForCatalog():
default_expression = vdef.getDefaultExpression()
variable_expression = vdef.getVariableExpression()
if status.has_key(vdef_ref):
value = status[vdef_ref]
# Not set yet. Use a default.
elif default_expression is not None:
elif variable_expression is not None:
ec = createExprContext(StateChangeInfo(ob, self, status))
# convert string to expression before execute it.
value = Expression(default_expression)(ec)
value = Expression(variable_expression)(ec)
else:
value = vdef.getVariableValue()
if hasattr(self, 'getSourceValue'):
......
......@@ -144,7 +144,7 @@ class Worklist(IdAsReferenceMixin("worklist_", "prefix"), XMLObject):
variable_value_ref = variable_value.getReference()
worklist_variable_value = self.newContent(portal_type='Worklist Variable')
worklist_variable_value.setReference(variable_value_ref)
worklist_variable_value.setDefaultExpression(variable_value.getDefaultExpression())
worklist_variable_value.setVariableExpression(variable_value.getVariableExpression())
worklist_variable_value.setVariableValue(variable_value.getVariableValue())
res.append(worklist_variable_value)
if worklist_variable_value and worklist_variable_value not in res and variable_value.getForCatalog() == 1:
......@@ -174,7 +174,7 @@ class Worklist(IdAsReferenceMixin("worklist_", "prefix"), XMLObject):
if self.getMatchedCausalityState() is not None:
key_list.append('causality_state')
for dynamic_variable in self.objectValues():
if dynamic_variable.getVariableValue() or dynamic_variable.getDefaultExpression():
if dynamic_variable.getVariableValue() or dynamic_variable.getVariableExpression():
key_list.append(dynamic_variable.getReference())
return key_list
......@@ -206,8 +206,8 @@ class Worklist(IdAsReferenceMixin("worklist_", "prefix"), XMLObject):
if dynamic_variable.getVariableValue():
matches = [dynamic_variable.getVariableValue()]
# Override initial value if expression set:
if dynamic_variable.getDefaultExpression():
matches = Expression(dynamic_variable.getDefaultExpression())
if dynamic_variable.getVariableExpression():
matches = Expression(dynamic_variable.getVariableExpression())
if matches is not [] and matches is not None:
if not isinstance(matches, (tuple, Expression)):
......
......@@ -39,7 +39,7 @@ class WorklistVariable(IdAsReferenceMixin("variable_", "prefix"), XMLObject):
This type of object has 3 values:
- reference as Title;
- variable_value;
- default_expression which will override default when it's set.
- variable_expression which will override default when it's set.
"""
meta_type = 'ERP5 Variable'
......@@ -49,7 +49,7 @@ class WorklistVariable(IdAsReferenceMixin("variable_", "prefix"), XMLObject):
isRADContent = 1
variable_value = ''
default_expression = None # Overrides variable_value if set
variable_expression = None # Overrides variable_value if set
default_reference = ''
# Declarative security
security = ClassSecurityInfo()
......
......@@ -408,7 +408,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
worklist_variable_value = worklist.newContent(portal_type='Worklist Variable',
reference=key)
if isinstance(values, Expression):
worklist_variable_value.setDefaultExpression(values.text)
worklist_variable_value.setVariableExpression(values.text)
else:
worklist_variable_value.setVariableValue(values)
......@@ -505,9 +505,9 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
# for a very specific case, action return the reference of transition
# in order to generation correct workflow history.
if variable_id == 'action':
variable.setDefaultExpression('transition/getReference|nothing')
variable.setVariableExpression('transition/getReference|nothing')
else:
variable.setDefaultExpression(variable_definition.default_expr.text)
variable.setVariableExpression(variable_definition.default_expr.text)
if variable_definition.info_guard:
variable.info_guard = variable_definition.info_guard
variable.setRoleList(variable_definition.info_guard.roles)
......@@ -532,7 +532,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
else: var_exprs = origin_tdef.var_exprs
for key in var_exprs:
tr_var = transition.newContent(portal_type='Transition Variable', temp_object=is_temporary)
tr_var.setDefaultExpression(var_exprs[key].text)
tr_var.setVariableExpression(var_exprs[key].text)
tr_var_path = getattr(workflow, 'variable_'+key).getPath()
tr_var_path = '/'.join(tr_var_path.split('/')[2:])
new_category.append(tr_var_path)
......@@ -549,7 +549,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
else: var_exprs = origin_tdef.var_exprs
for key in var_exprs:
tr_var = interaction.newContent(portal_type='Transition Variable', temp_object=is_temporary)
tr_var.setDefaultExpression(var_exprs[key].text)
tr_var.setVariableExpression(var_exprs[key].text)
tr_var_path = getattr(workflow, 'variable_'+key).getPath()
tr_var_path = '/'.join(tr_var_path.split('/')[2:])
new_category.append(tr_var_path)
......
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