From a32aac508f48792f3c555fbf218f40160b93fcbc Mon Sep 17 00:00:00 2001
From: Ivan Tyagov <ivan@nexedi.com>
Date: Mon, 30 Jan 2012 08:02:12 +0000
Subject: [PATCH] Prevent needless failures by trying to execute an alarm which
 is not enabled.

---
 .../scripts/Call_alarmActiveSense.xml                    | 9 +++++++--
 bt5/erp5_credential/bt/revision                          | 2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/bt5/erp5_credential/WorkflowTemplateItem/portal_workflow/credential_interaction_workflow/scripts/Call_alarmActiveSense.xml b/bt5/erp5_credential/WorkflowTemplateItem/portal_workflow/credential_interaction_workflow/scripts/Call_alarmActiveSense.xml
index e57dfe7cd9..d2a5972488 100644
--- a/bt5/erp5_credential/WorkflowTemplateItem/portal_workflow/credential_interaction_workflow/scripts/Call_alarmActiveSense.xml
+++ b/bt5/erp5_credential/WorkflowTemplateItem/portal_workflow/credential_interaction_workflow/scripts/Call_alarmActiveSense.xml
@@ -53,8 +53,13 @@
             <value> <string>portal = state_change[\'object\'].getPortalObject()\n
 tag = \'%s_reindex\' % state_change[\'object\'].getRelativeUrl()\n
 activate_kw = {\'tag\': tag} \n
-state_change[\'object\'].reindexObject(activate_kw=activate_kw) \n
-portal.portal_alarms.accept_submitted_credentials.activate(activity=\'SQLDict\', after_tag=tag).activeSense()\n
+state_change[\'object\'].reindexObject(activate_kw=activate_kw)\n
+\n
+# call alarm to speed up account creation process\n
+# only if alarm is enabled\n
+alarm = portal.portal_alarms.accept_submitted_credentials\n
+if alarm.isEnabled():\n
+  alarm.activate(activity=\'SQLDict\', after_tag=tag).activeSense()\n
 </string> </value>
         </item>
         <item>
diff --git a/bt5/erp5_credential/bt/revision b/bt5/erp5_credential/bt/revision
index 0ad1c6bd53..d9beed0e29 100644
--- a/bt5/erp5_credential/bt/revision
+++ b/bt5/erp5_credential/bt/revision
@@ -1 +1 @@
-408
\ No newline at end of file
+409
\ No newline at end of file
-- 
2.30.9