From d7f7f484c3a6e42cdb543ee89f1fd495c71f3602 Mon Sep 17 00:00:00 2001
From: Rafael Monnerat <rafael@nexedi.com>
Date: Tue, 12 Oct 2010 20:23:25 +0000
Subject: [PATCH] Allow flexibility. Call before script before sense.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39076 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../erp5_upgrader/Alarm_senseUpgradeNeed.xml    | 17 ++++++++++-------
 .../erp5_upgrader/ERP5Site_upgradeSecurity.xml  |  2 --
 bt5/erp5_upgrader/bt/revision                   |  2 +-
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/bt5/erp5_upgrader/SkinTemplateItem/portal_skins/erp5_upgrader/Alarm_senseUpgradeNeed.xml b/bt5/erp5_upgrader/SkinTemplateItem/portal_skins/erp5_upgrader/Alarm_senseUpgradeNeed.xml
index 2a55fe40ad..44471b5723 100644
--- a/bt5/erp5_upgrader/SkinTemplateItem/portal_skins/erp5_upgrader/Alarm_senseUpgradeNeed.xml
+++ b/bt5/erp5_upgrader/SkinTemplateItem/portal_skins/erp5_upgrader/Alarm_senseUpgradeNeed.xml
@@ -2,10 +2,7 @@
 <ZopeData>
   <record id="1" aka="AAAAAAAAAAE=">
     <pickle>
-      <tuple>
-        <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
-        <tuple/>
-      </tuple>
+      <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
     </pickle>
     <pickle>
       <dictionary>
@@ -65,6 +62,11 @@ It will start an instance upgrade if any of the following alarms:\n
 "sense" a need of an upgrade. This alarm is likely to disappear soon as it\'s needed \n
  due to lack of functionality (which is that alarms can not automatically "solve" themselves).\n
 """\n
+# If before script is present call it.\n
+before_script = getattr(context, \'ERP5Site_beforeSenseUpgrade\', None)\n
+if before_script is not None:\n
+  before_script()\n
+\n
 context.ERP5Site_setupUpgraderSkinSelection()\n
 \n
 portal_alarms = context.getPortalObject().portal_alarms\n
@@ -178,11 +180,13 @@ return\n
                         <key> <string>co_varnames</string> </key>
                         <value>
                           <tuple>
-                            <string>_getattr_</string>
+                            <string>getattr</string>
                             <string>context</string>
+                            <string>None</string>
+                            <string>before_script</string>
+                            <string>_getattr_</string>
                             <string>portal_alarms</string>
                             <string>activate</string>
-                            <string>None</string>
                             <string>previous_tag</string>
                             <string>active_process</string>
                             <string>DateTime</string>
@@ -190,7 +194,6 @@ return\n
                             <string>previous_method_id</string>
                             <string>_getiter_</string>
                             <string>alarm_id</string>
-                            <string>getattr</string>
                             <string>upgrader_alarm</string>
                             <string>False</string>
                           </tuple>
diff --git a/bt5/erp5_upgrader/SkinTemplateItem/portal_skins/erp5_upgrader/ERP5Site_upgradeSecurity.xml b/bt5/erp5_upgrader/SkinTemplateItem/portal_skins/erp5_upgrader/ERP5Site_upgradeSecurity.xml
index 0694fe815b..2efff9adc3 100644
--- a/bt5/erp5_upgrader/SkinTemplateItem/portal_skins/erp5_upgrader/ERP5Site_upgradeSecurity.xml
+++ b/bt5/erp5_upgrader/SkinTemplateItem/portal_skins/erp5_upgrader/ERP5Site_upgradeSecurity.xml
@@ -73,8 +73,6 @@ for pt in portal_type_list:\n
   portal_type_document = getattr(context.portal_types, pt, None )\n
   if portal_type_document is not None:\n
     portal_type_document.updateRoleMapping()\n
-  else:\n
-    message_list.append("Unable to upgrade security on %s portal type because it is not present on portal." % pt)\n
 \n
 message_list.append(\n
             "Update Local Roles for security groups for: \\n\\t%s" % \\\n
diff --git a/bt5/erp5_upgrader/bt/revision b/bt5/erp5_upgrader/bt/revision
index db3a73389d..d759b56ecc 100644
--- a/bt5/erp5_upgrader/bt/revision
+++ b/bt5/erp5_upgrader/bt/revision
@@ -1 +1 @@
-536
\ No newline at end of file
+537
\ No newline at end of file
-- 
2.30.9