Commit 62f554bd authored by Rafael Monnerat's avatar Rafael Monnerat

Update Upgrader signature and clean up to allow some steps be done automatically or ignored.

Refactor ERP5Site_upgradeValidationStateList into something more generic which can be used to any workflow or script. Rename the script to ERP5Site_upgradeObjectList.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42315 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7f9a7a86
...@@ -54,11 +54,11 @@ ...@@ -54,11 +54,11 @@
It is expected that some objects has some state in the after upgrade finish.\n It is expected that some objects has some state in the after upgrade finish.\n
This alarm verify and upgrade the objects that were defined in signature.\n This alarm verify and upgrade the objects that were defined in signature.\n
"""\n """\n
from Products.ERP5Type.Log import log\n
portal_templates = context.portal_templates\n portal_templates = context.portal_templates\n
signature = context.ERP5Site_getUpgraderSignature()\n validation_dict = context.ERP5Site_getUpgraderSignature(\'validation_dict\')\n
validation_dict = signature[ \'validation_dict\']\n param_not_provided = "PARAM_NOT_PROVIDED"\n
release = signature[\'release\']\n \n
upgrade = int(upgrade)\n
# get list of title of bt5 that are installed.\n # get list of title of bt5 that are installed.\n
installed_bt5_title_list = [t.getTitle() for t in portal_templates.getInstalledBusinessTemplateList()]\n installed_bt5_title_list = [t.getTitle() for t in portal_templates.getInstalledBusinessTemplateList()]\n
\n \n
...@@ -70,110 +70,42 @@ for k in validation_dict.keys():\n ...@@ -70,110 +70,42 @@ for k in validation_dict.keys():\n
\n \n
message_list = []\n message_list = []\n
for definition in upgradable_list:\n for definition in upgradable_list:\n
if len(definition) == 5:\n
path, method_id, expected_state, action, param_list = definition\n
else:\n
path, method_id, expected_state, action = definition\n
param_list = param_not_provided\n
sub_message_list = []\n sub_message_list = []\n
path, expected_state, action = definition\n try:\n
obj = context.restrictedTraverse(path)\n obj = context.restrictedTraverse(path)\n
if obj is not None and \\\n except KeyError:\n
getattr(obj, \'getValidationState\', None) is not None and \\\n obj = None\n
obj.getValidationState() == expected_state:\n log("Unable to find %s" % path)\n
\n if obj is not None:\n
sub_message_list.append("Upgrade is required for Validation Workflow List (%s object is in %s state, action %s.)" %\n method = getattr(obj, method_id, None)\n
if method is not None and method() == expected_state:\n
sub_message_list.append("Upgrade is required for Validation Workflow List (%s object is in %s state, action %s.)" %\n
(path, expected_state, action))\n (path, expected_state, action))\n
if upgrade == 1:\n if int(upgrade) == 1:\n
workflow_method = getattr(obj, action , None)\n action_method = getattr(obj, action , None)\n
if workflow_method is not None:\n if action_method is not None:\n
workflow_method()\n if param_list == param_not_provided:\n
sub_message_list.append("updated")\n action_method()\n
else:\n
action_method(*param_list)\n
sub_message_list.append("updated")\n
message_list.append(\' \'.join(sub_message_list))\n message_list.append(\' \'.join(sub_message_list))\n
\n \n
return message_list\n return message_list\n
</string> </value> </string> </value>
</item> </item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>upgrade=0</string> </value> <value> <string>upgrade=0</string> </value>
</item> </item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>upgrade</string>
<string>_getattr_</string>
<string>context</string>
<string>portal_templates</string>
<string>signature</string>
<string>_getitem_</string>
<string>validation_dict</string>
<string>release</string>
<string>int</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>t</string>
<string>installed_bt5_title_list</string>
<string>upgradable_list</string>
<string>k</string>
<string>message_list</string>
<string>definition</string>
<string>sub_message_list</string>
<string>path</string>
<string>expected_state</string>
<string>action</string>
<string>obj</string>
<string>None</string>
<string>getattr</string>
<string>workflow_method</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<int>0</int>
</tuple>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>ERP5Site_upgradeValidationStateList</string> </value> <value> <string>ERP5Site_upgradeObjectList</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
555 556
\ No newline at end of file \ No newline at end of file
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