Commit 22b179f3 authored by wenjie.zheng's avatar wenjie.zheng

Variable.py: remove setProperties which can be replace by edit.

parent 5613e596
...@@ -50,7 +50,58 @@ ...@@ -50,7 +50,58 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>context.initialDefaultWorkflow()\n <value> <string>"""Sets up an Workflow with defaults variables needed by ERP5.\n
"""\n
for state_id, state_title in ((\'draft\', \'Draft\'),):\n
state = context.newContent(portal_type=\'State\')\n
state.setReference(state_id)\n
state.setTitle(state_title)\n
context.setSourceValue(state)\n
\n
for v, property_dict in (\n
(\'action\', {\n
\'description\': \'Transition id\',\n
\'default_expr\': \'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_expr\': \'user/getUserName\',\n
\'for_status\': 1,\n
\'automatic_update\': 1,\n
}),\n
(\'comment\', {\n
\'description\': \'Comment about transition\',\n
\'default_expr\': "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_expr\': \'state_change/getHistory\',\n
}),\n
(\'time\', {\n
\'description\': \'Transition timestamp\',\n
\'default_expr\': \'state_change/getDateTime\',\n
\'for_status\': 1,\n
\'automatic_update\': 1,\n
}),\n
(\'error_message\', {\n
\'description\': \'Error message if validation failed\',\n
\'for_status\': 1,\n
\'automatic_update\': 1,\n
}),\n
(\'portal_type\', {\n
\'description\': \'Portal type (used as filter for worklists)\',\n
\'for_catalog\': 1,\n
}),\n
):\n
variable = context.newContent(portal_type=\'Variable\')\n
variable.setReference(v)\n
variable.edit(**property_dict)\n
\n
context.setStateVariable(\'simulation_state\')\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
...@@ -91,34 +91,11 @@ class Variable(IdAsReferenceMixin("variable_", "prefix"), XMLObject): ...@@ -91,34 +91,11 @@ class Variable(IdAsReferenceMixin("variable_", "prefix"), XMLObject):
def getInfoGuard(self): def getInfoGuard(self):
if self.info_guard is not None: if self.info_guard is not None:
self.generateGuard() self.generateInfoGuard()
return self.info_guard return self.info_guard
def getInfoGuardSummary(self): def getInfoGuardSummary(self):
res = None res = None
if self.info_guard is not None: if self.info_guard is not None:
res = self.info_guard.getSummary() res = self.info_guard.getSummary()
return res return res
\ No newline at end of file
# initial pre-configured workflow's variables
def setProperties(self, description,
default_value='', default_expr='',
for_catalog=0, for_status=0,
update_always=0,
props=None, REQUEST=None):
self.setDescription(str(description))
self.setInitialValue(str(default_value))
if default_expr:
self.setDefaultExpr(default_expr)
else:
self.default_expr = None
g = Guard()
if g.changeFromProperties(props or REQUEST):
self.info_guard = g
else:
self.info_guard = None
self.setForCatalog(bool(for_catalog))
self.setForStatus(bool(for_status))
self.setAutomaticUpdate(bool(update_always))
if REQUEST is not None:
return self.manage_properties(REQUEST, 'Properties changed.')
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