Commit 3107b0e3 authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_upgrader: Clean up scripts and set tag in searchAndActivate when called.

With this, is possible wait those activities finish before start the next upgrader phase
parent 5d1e50f7
......@@ -50,48 +50,15 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
"""\n
<value> <string>"""\n
Run upgrader\n
"""\n
portal = context.getPortalObject()\n
portal_alarms = portal.portal_alarms\n
\n
def launchUpgraderAlarm(alarm_id, after_method_id=[]):\n
""" Get the alarm and use sense and solve """\n
upgrader_alarm = getattr(portal_alarms, alarm_id, None)\n
if upgrader_alarm is not None and upgrader_alarm.sense():\n
# call solve method\n
kw = dict(tag=alarm_id)\n
if len(after_method_id) > 0:\n
kw["after_method_id"] = after_method_id\n
method_id = upgrader_alarm.getSolveMethodId()\n
if method_id not in (None, \'\'):\n
method = getattr(upgrader_alarm.activate(**kw), method_id)\n
method()\n
return [method_id] + after_method_id\n
return after_method_id\n
\n
previous_method_id = launchUpgraderAlarm(\'upgrader_check_pre_upgrade\')\n
\n
previous_method_id.extend([\'recursiveImmediateReindexObject\',\n
\'immediateReindexObject\',\n
\'callMethodOnObjectList\'])\n
\n
previous_method_id = launchUpgraderAlarm(\'upgrader_check_upgrader\',\n
after_method_id=previous_method_id)\n
\n
previous_method_id.append(\'updateBusinessTemplateFromUrl\')\n
previous_method_id = launchUpgraderAlarm(\'upgrader_check_post_upgrade\',\n
after_method_id=previous_method_id)\n
context.Alarm_senseFullUpgradeNeed(fixit=True)\n
\n
# Nothing else to do, so we can disable.\n
context.setEnabled(False)\n
return\n
]]></string> </value>
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
......
......@@ -61,8 +61,8 @@ alarm = getattr(portal_alarms, \'upgrader_check_upgrader\')\n
if alarm.sense() in (None, True):\n
active_process.postActiveResult(summary=context.getTitle(),\n
severity=1,\n
detail="Is required run upgrade before solve it. " +\\\n
"You need run active sense once at least on this alarm")\n
detail=["Is required run upgrade before solve it. " +\\\n
"You need run active sense once at least on this alarm",])\n
return\n
\n
context.ERP5Site_checkUpgraderConsistency(fixit=True,\n
......
......@@ -70,8 +70,8 @@ alarm = getattr(portal_alarms, \'upgrader_check_pre_upgrade\')\n
if alarm.sense() in (None, True):\n
active_process.postActiveResult(summary=context.getTitle(),\n
severity=1,\n
detail="Is required solve Pre Upgrade first. " +\\\n
"You need run active sense once at least on this alarm")\n
detail=["Is required solve Pre Upgrade first. " +\\\n
"You need run active sense once at least on this alarm",])\n
return\n
\n
_, type_per_constraint_type = context.Base_getConstraintTypeListPerPortalType()\n
......@@ -91,6 +91,7 @@ for portal_type in portal_type_list:\n
portal_type=portal_type_list)[0][0] > REINDEX_SPLIT_COUNT:\n
portal.portal_catalog.searchAndActivate(\'Base_postCheckConsistencyResult\',\n
portal_type=portal_type,\n
activate_kw={"tag": "erp5_upgrader"},\n
method_kw=method_kw)\n
else:\n
for result in portal.portal_catalog(portal_type=portal_type):\n
......
......@@ -50,50 +50,44 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
"""\n
<value> <string>"""\n
Run upgrader\n
"""\n
portal = context.getPortalObject()\n
portal_alarms = portal.portal_alarms\n
\n
after_method_id = \'callMethodOnObjectList\'\n
def launchSenseAlarm(alarm_id, after_tag=[]):\n
def launchSenseAlarm(alarm_id, after_tag_list):\n
""" Get the alarm and use sense"""\n
upgrader_alarm = getattr(portal_alarms, alarm_id, None)\n
assert upgrader_alarm, "%s not found" % alarm_id\n
if upgrader_alarm is not None:\n
# call solve method\n
kw = {"tag": alarm_id,\n
"after_method_id": after_method_id}\n
if len(after_tag) > 0:\n
kw["after_tag"] = after_tag\n
method_id = upgrader_alarm.getActiveSenseMethodId()\n
if method_id not in (None, \'\'):\n
method = getattr(upgrader_alarm.activate(**kw), method_id)\n
method()\n
return [alarm_id,]\n
return after_tag\n
"after_tag": after_tag_list}\n
if fixit:\n
method_id = upgrader_alarm.getSolveMethodId()\n
else:\n
method_id = upgrader_alarm.getActiveSenseMethodId()\n
assert method_id, "Missing method id in %s" % alarm_id\n
getattr(upgrader_alarm.activate(**kw), method_id)()\n
return after_tag_list + [alarm_id,]\n
\n
previous_tag = launchSenseAlarm(\'upgrader_check_pre_upgrade\')\n
previous_tag = launchSenseAlarm(\'upgrader_check_pre_upgrade\',\n
[\'erp5_upgrader\',])\n
\n
previous_tag = launchSenseAlarm(\'upgrader_check_upgrader\',\n
after_tag=previous_tag)\n
after_tag_list=previous_tag)\n
\n
previous_tag = launchSenseAlarm(\'upgrader_check_post_upgrade\',\n
after_tag=previous_tag)\n
after_tag_list=previous_tag)\n
\n
active_process = context.newActiveProcess()\n
context.activate(after_tag=previous_tag,\n
after_method_id=after_method_id).Alarm_postFullUpgradeNeed(\n
context.activate(after_tag=previous_tag).Alarm_postFullUpgradeNeed(\n
active_process=active_process.getRelativeUrl())\n
]]></string> </value>
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None, **kw</string> </value>
<value> <string>fixit=0, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -65,6 +65,7 @@ if portal_type_list:\n
context.getPortalObject().portal_catalog.searchAndActivate(\n
\'Base_postCheckConsistencyResult\',\n
portal_type=portal_type_list,\n
activate_kw={"tag": "erp5_upgrader"},\n
method_kw={\n
\'fixit\': fixit,\n
\'filter\': filter_dict,\n
......
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