Commit 01b1f24c authored by Arnaud Fontaine's avatar Arnaud Fontaine

ERP5Workflow: Remove unused variable_default_value...

ERP5Workflow: Remove unused variable_default_value (variable_default_expression should be used instead).
parent 3a3547fc
......@@ -84,7 +84,6 @@
<value>
<list>
<string>my_causality</string>
<string>my_variable_default_value</string>
<string>my_variable_default_expression</string>
</list>
</value>
......
default_value = context.getVariableDefaultExpression(evaluate=0)
if default_value is None:
# variable_default_expression takes precedence over "static" variable_default_value property
default_value = repr(context.getVariableDefaultValue())
return default_value
return context.getVariableDefaultExpression(evaluate=0)
......@@ -91,7 +91,6 @@
<string>my_for_catalog</string>
<string>my_status_included</string>
<string>my_automatic_update</string>
<string>my_variable_default_value</string>
<string>my_variable_default_expression</string>
</list>
</value>
......
......@@ -87,7 +87,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Default Expression (Overrides Default Value)</string> </value>
<value> <string>Default Expression</string> </value>
</item>
</dictionary>
</value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>mode</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Defines the default value (default_expression property takes precedence).</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_default_value_property</string> </value>
</item>
<item>
<key> <string>mode</string> </key>
<value> <string>w</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>property_default</string> </key>
<value> <string>python: \'\'</string> </value>
</item>
<item>
<key> <string>storage_id</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -125,7 +125,7 @@ class InteractionWorkflow(Workflow):
ec = createExpressionContext(StateChangeInfo(ob, self, status))
value = variable_default_expression(ec)
else:
value = vdef.getVariableDefaultValue()
value = ''
return value
......@@ -250,6 +250,7 @@ class InteractionWorkflow(Workflow):
if not vdef.getStatusIncluded():
continue
expression = None
value = ''
if not vdef.getAutomaticUpdate() and id_ in former_status:
# Preserve former value
value = former_status[id_]
......@@ -257,8 +258,6 @@ class InteractionWorkflow(Workflow):
variable_default_expression = vdef.getVariableDefaultExpression()
if variable_default_expression is not None:
expression = variable_default_expression
else:
value = vdef.getVariableDefaultValue()
if expression is not None:
# Evaluate an expression.
if econtext is None:
......@@ -436,7 +435,7 @@ class InteractionWorkflow(Workflow):
# 2. Variable as XML
variable_reference_list = []
variable_list = self.objectValues(portal_type='Workflow Variable')
variable_prop_id_to_show = ['description', 'variable_default_value', 'variable_default_expression',
variable_prop_id_to_show = ['description', 'variable_default_expression',
'for_catalog', 'for_status', 'automatic_update']
for vdef in variable_list:
variable_reference_list.append(vdef.getReference())
......@@ -449,9 +448,6 @@ class InteractionWorkflow(Workflow):
if property_id == 'automatic_update':
property_value = vdef.getAutomaticUpdate()
sub_object = SubElement(variable, property_id, attrib=dict(type='int'))
elif property_id == 'variable_default_value':
property_value = vdef.getVariableDefaultValue()
sub_object = SubElement(variable, property_id, attrib=dict(type='string'))
else:
property_value = vdef.getProperty(property_id)
property_type = vdef.getPropertyType(property_id)
......
......@@ -572,7 +572,7 @@ class Workflow(XMLObject):
ec = createExpressionContext(StateChangeInfo(ob, self, status))
value = variable_default_expression(ec)
else:
value = vdef.getVariableDefaultValue()
value = ''
return value
......@@ -856,9 +856,7 @@ class Workflow(XMLObject):
else:
expr = variable_default_expression
else:
if object_context is None:
object_context = self.getStateChangeInformation(ob, self.getSourceValue())
value = vdef.getVariableDefaultValue(object=object_context)
value = ''
if expr not in (None, ''):
# Evaluate an expression.
......@@ -1091,7 +1089,7 @@ class Workflow(XMLObject):
# 3. Variable as XML
variable_reference_list = []
variable_list = self.getVariableValueList()
variable_prop_id_to_show = ['description', 'variable_default_value', 'variable_default_expression',
variable_prop_id_to_show = ['description', 'variable_default_expression',
'for_catalog', 'for_status', 'automatic_update']
for vdef in variable_list:
variable_reference_list.append(vdef.getReference())
......@@ -1104,9 +1102,6 @@ class Workflow(XMLObject):
if property_id == 'automatic_update':
property_value = vdef.getAutomaticUpdate()
sub_object = SubElement(variable, property_id, attrib=dict(type='int'))
elif property_id == 'variable_default_value':
property_value = vdef.getVariableDefaultValue()
sub_object = SubElement(variable, property_id, attrib=dict(type='string'))
else:
property_value = vdef.getProperty(property_id)
property_type = vdef.getPropertyType(property_id)
......@@ -1246,7 +1241,7 @@ class Workflow(XMLObject):
if variable_default_expression is not None:
expr = variable_default_expression
else:
value = vdef.getVariableDefaultValue()
value = ''
if expr is not None:
# Evaluate an expression.
if econtext is None:
......@@ -1290,7 +1285,7 @@ class Workflow(XMLObject):
# convert string to expression before execute it.
value = variable_default_expression(ec)
else:
value = variable.getVariableDefaultValue()
value = ''
res[variable_id] = value
......
......@@ -1121,6 +1121,13 @@ def convertToERP5Workflow(self, temp_object=False):
variable.setVariableDefaultExpression('transition/getReference|nothing')
else:
variable.setVariableDefaultExpression(variable_definition.default_expr.text)
# default_expr has precedence over default_value if defined...
elif variable_definition.default_value:
if '/' not in variable_definition.default_value:
default_value = 'python: %s' % variable_definition.default_value
else:
default_value = variable_definition.default_value
variable.setVariableDefaultExpression(default_value)
if variable_definition.info_guard:
variable.info_guard = variable_definition.info_guard
variable.setGuardRoleList(variable_definition.info_guard.roles)
......@@ -1131,12 +1138,6 @@ def convertToERP5Workflow(self, temp_object=False):
variable.setGuardExpression(tdef.info_guard.expr.text)
variable.setForCatalog(variable_definition.for_catalog)
variable.setStatusIncluded(variable_definition.for_status)
# setVariableValue sets the value to None if the parameter is an empty
# string. This change the expected behaviour.
# XXX(WORKFLOW): you need to be aware that if someone saves a variable
# without editing this field, variable_value may be None again
if variable_definition.default_value:
variable.setVariableDefaultValue(variable_definition.default_value)
variable.setDescription(variable_definition.description)
# Configure transition variable:
if getattr(self, 'transitions', None) is not None:
......@@ -1256,7 +1257,6 @@ VariableDefinition.getId = method_getId
VariableDefinition.getTitle = method_getTitle
VariableDefinition.getDescription = method_getDescription
VariableDefinition.getVariableDefaultExpression = lambda self: self.var_expr
VariableDefinition.getVariableDefaultValue = lambda self: self.default_value
VariableDefinition.checkGuard = method_checkGuard
VariableDefinition.showDict = DCWorkflowDefinition_showDict
VariableDefinition.getStatusIncluded = lambda self: self.for_status
......
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