[Erp5-report] r19126 - /erp5/trunk/products/ERP5/Tool/NotificationTool.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Feb 7 14:45:18 CET 2008


Author: romain
Date: Thu Feb  7 14:45:18 2008
New Revision: 19126

URL: http://svn.erp5.org?rev=19126&view=rev
Log:
Improve multi recipient behaviour.
Raise error if a Person doesn't have an email address.

Modified:
    erp5/trunk/products/ERP5/Tool/NotificationTool.py

Modified: erp5/trunk/products/ERP5/Tool/NotificationTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Tool/NotificationTool.py?rev=19126&r1=19125&r2=19126&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Tool/NotificationTool.py (original)
+++ erp5/trunk/products/ERP5/Tool/NotificationTool.py Thu Feb  7 14:45:18 2008
@@ -142,7 +142,8 @@
   manage_overview = DTMLFile( 'explainNotificationTool', _dtmldir )
 
   security.declareProtected(Permissions.UseMailhostServices, 'sendMessage')
-  def sendMessage(self, sender=None, recipient=None, subject=None, message=None, attachment_list=None):
+  def sendMessage(self, sender=None, recipient=None, subject=None, 
+                  message=None, attachment_list=None):
     """
       This method provides a common API to send messages to users
       from object actions of worflow scripts.
@@ -182,7 +183,7 @@
 
     # To is a list - let us find all members
     if isinstance(recipient, basestring):
-      recipient = catalog_tool(portal_type='Person', reference=recipient)
+      recipient = (recipient, )
 
     # If no recipient is defined, just send an email to the
     # default mail address defined at the CMF site root.
@@ -197,6 +198,8 @@
 
     # Default implementation is to send an active message to everyone
     for person in recipient:
+      if isinstance(person, basestring):
+        person = catalog_tool(portal_type='Person', reference=person)[0]
       email_value = person.getDefaultEmailValue()
       if email_value is not None:
         # Activity can not handle attachment
@@ -207,6 +210,9 @@
                           subject=subject,
                           msg=message,
                           attachment_list=attachment_list)
+      else:
+        raise AttributeError, \
+            "Can not contact the person %s" % person.getReference()
 
     # Future implemetation could consist in implementing
     # policies such as grouped notification (per hour, per day,




More information about the Erp5-report mailing list