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 @@ ...@@ -84,7 +84,6 @@
<value> <value>
<list> <list>
<string>my_causality</string> <string>my_causality</string>
<string>my_variable_default_value</string>
<string>my_variable_default_expression</string> <string>my_variable_default_expression</string>
</list> </list>
</value> </value>
......
default_value = context.getVariableDefaultExpression(evaluate=0) return 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
...@@ -91,7 +91,6 @@ ...@@ -91,7 +91,6 @@
<string>my_for_catalog</string> <string>my_for_catalog</string>
<string>my_status_included</string> <string>my_status_included</string>
<string>my_automatic_update</string> <string>my_automatic_update</string>
<string>my_variable_default_value</string>
<string>my_variable_default_expression</string> <string>my_variable_default_expression</string>
</list> </list>
</value> </value>
......
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Default Expression (Overrides Default Value)</string> </value> <value> <string>Default Expression</string> </value>
</item> </item>
</dictionary> </dictionary>
</value> </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): ...@@ -125,7 +125,7 @@ class InteractionWorkflow(Workflow):
ec = createExpressionContext(StateChangeInfo(ob, self, status)) ec = createExpressionContext(StateChangeInfo(ob, self, status))
value = variable_default_expression(ec) value = variable_default_expression(ec)
else: else:
value = vdef.getVariableDefaultValue() value = ''
return value return value
...@@ -250,6 +250,7 @@ class InteractionWorkflow(Workflow): ...@@ -250,6 +250,7 @@ class InteractionWorkflow(Workflow):
if not vdef.getStatusIncluded(): if not vdef.getStatusIncluded():
continue continue
expression = None expression = None
value = ''
if not vdef.getAutomaticUpdate() and id_ in former_status: if not vdef.getAutomaticUpdate() and id_ in former_status:
# Preserve former value # Preserve former value
value = former_status[id_] value = former_status[id_]
...@@ -257,8 +258,6 @@ class InteractionWorkflow(Workflow): ...@@ -257,8 +258,6 @@ class InteractionWorkflow(Workflow):
variable_default_expression = vdef.getVariableDefaultExpression() variable_default_expression = vdef.getVariableDefaultExpression()
if variable_default_expression is not None: if variable_default_expression is not None:
expression = variable_default_expression expression = variable_default_expression
else:
value = vdef.getVariableDefaultValue()
if expression is not None: if expression is not None:
# Evaluate an expression. # Evaluate an expression.
if econtext is None: if econtext is None:
...@@ -436,7 +435,7 @@ class InteractionWorkflow(Workflow): ...@@ -436,7 +435,7 @@ class InteractionWorkflow(Workflow):
# 2. Variable as XML # 2. Variable as XML
variable_reference_list = [] variable_reference_list = []
variable_list = self.objectValues(portal_type='Workflow Variable') 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_catalog', 'for_status', 'automatic_update']
for vdef in variable_list: for vdef in variable_list:
variable_reference_list.append(vdef.getReference()) variable_reference_list.append(vdef.getReference())
...@@ -449,9 +448,6 @@ class InteractionWorkflow(Workflow): ...@@ -449,9 +448,6 @@ class InteractionWorkflow(Workflow):
if property_id == 'automatic_update': if property_id == 'automatic_update':
property_value = vdef.getAutomaticUpdate() property_value = vdef.getAutomaticUpdate()
sub_object = SubElement(variable, property_id, attrib=dict(type='int')) 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: else:
property_value = vdef.getProperty(property_id) property_value = vdef.getProperty(property_id)
property_type = vdef.getPropertyType(property_id) property_type = vdef.getPropertyType(property_id)
......
...@@ -572,7 +572,7 @@ class Workflow(XMLObject): ...@@ -572,7 +572,7 @@ class Workflow(XMLObject):
ec = createExpressionContext(StateChangeInfo(ob, self, status)) ec = createExpressionContext(StateChangeInfo(ob, self, status))
value = variable_default_expression(ec) value = variable_default_expression(ec)
else: else:
value = vdef.getVariableDefaultValue() value = ''
return value return value
...@@ -856,9 +856,7 @@ class Workflow(XMLObject): ...@@ -856,9 +856,7 @@ class Workflow(XMLObject):
else: else:
expr = variable_default_expression expr = variable_default_expression
else: else:
if object_context is None: value = ''
object_context = self.getStateChangeInformation(ob, self.getSourceValue())
value = vdef.getVariableDefaultValue(object=object_context)
if expr not in (None, ''): if expr not in (None, ''):
# Evaluate an expression. # Evaluate an expression.
...@@ -1091,7 +1089,7 @@ class Workflow(XMLObject): ...@@ -1091,7 +1089,7 @@ class Workflow(XMLObject):
# 3. Variable as XML # 3. Variable as XML
variable_reference_list = [] variable_reference_list = []
variable_list = self.getVariableValueList() 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_catalog', 'for_status', 'automatic_update']
for vdef in variable_list: for vdef in variable_list:
variable_reference_list.append(vdef.getReference()) variable_reference_list.append(vdef.getReference())
...@@ -1104,9 +1102,6 @@ class Workflow(XMLObject): ...@@ -1104,9 +1102,6 @@ class Workflow(XMLObject):
if property_id == 'automatic_update': if property_id == 'automatic_update':
property_value = vdef.getAutomaticUpdate() property_value = vdef.getAutomaticUpdate()
sub_object = SubElement(variable, property_id, attrib=dict(type='int')) 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: else:
property_value = vdef.getProperty(property_id) property_value = vdef.getProperty(property_id)
property_type = vdef.getPropertyType(property_id) property_type = vdef.getPropertyType(property_id)
...@@ -1246,7 +1241,7 @@ class Workflow(XMLObject): ...@@ -1246,7 +1241,7 @@ class Workflow(XMLObject):
if variable_default_expression is not None: if variable_default_expression is not None:
expr = variable_default_expression expr = variable_default_expression
else: else:
value = vdef.getVariableDefaultValue() value = ''
if expr is not None: if expr is not None:
# Evaluate an expression. # Evaluate an expression.
if econtext is None: if econtext is None:
...@@ -1290,7 +1285,7 @@ class Workflow(XMLObject): ...@@ -1290,7 +1285,7 @@ class Workflow(XMLObject):
# convert string to expression before execute it. # convert string to expression before execute it.
value = variable_default_expression(ec) value = variable_default_expression(ec)
else: else:
value = variable.getVariableDefaultValue() value = ''
res[variable_id] = value res[variable_id] = value
......
...@@ -1121,6 +1121,13 @@ def convertToERP5Workflow(self, temp_object=False): ...@@ -1121,6 +1121,13 @@ def convertToERP5Workflow(self, temp_object=False):
variable.setVariableDefaultExpression('transition/getReference|nothing') variable.setVariableDefaultExpression('transition/getReference|nothing')
else: else:
variable.setVariableDefaultExpression(variable_definition.default_expr.text) 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: if variable_definition.info_guard:
variable.info_guard = variable_definition.info_guard variable.info_guard = variable_definition.info_guard
variable.setGuardRoleList(variable_definition.info_guard.roles) variable.setGuardRoleList(variable_definition.info_guard.roles)
...@@ -1131,12 +1138,6 @@ def convertToERP5Workflow(self, temp_object=False): ...@@ -1131,12 +1138,6 @@ def convertToERP5Workflow(self, temp_object=False):
variable.setGuardExpression(tdef.info_guard.expr.text) variable.setGuardExpression(tdef.info_guard.expr.text)
variable.setForCatalog(variable_definition.for_catalog) variable.setForCatalog(variable_definition.for_catalog)
variable.setStatusIncluded(variable_definition.for_status) 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) variable.setDescription(variable_definition.description)
# Configure transition variable: # Configure transition variable:
if getattr(self, 'transitions', None) is not None: if getattr(self, 'transitions', None) is not None:
...@@ -1256,7 +1257,6 @@ VariableDefinition.getId = method_getId ...@@ -1256,7 +1257,6 @@ VariableDefinition.getId = method_getId
VariableDefinition.getTitle = method_getTitle VariableDefinition.getTitle = method_getTitle
VariableDefinition.getDescription = method_getDescription VariableDefinition.getDescription = method_getDescription
VariableDefinition.getVariableDefaultExpression = lambda self: self.var_expr VariableDefinition.getVariableDefaultExpression = lambda self: self.var_expr
VariableDefinition.getVariableDefaultValue = lambda self: self.default_value
VariableDefinition.checkGuard = method_checkGuard VariableDefinition.checkGuard = method_checkGuard
VariableDefinition.showDict = DCWorkflowDefinition_showDict VariableDefinition.showDict = DCWorkflowDefinition_showDict
VariableDefinition.getStatusIncluded = lambda self: self.for_status 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