[Erp5-report] r15893 - /erp5/trunk/products/ERP5/Document/Url.py

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Aug 29 11:20:15 CEST 2007


Author: jerome
Date: Wed Aug 29 11:20:15 2007
New Revision: 15893

URL: http://svn.erp5.org?rev=15893&view=rev
Log:
pass _charset parameter by name, because the second positional argument is _subtype
Don't encode text/plain in base64, so that MUA can display it inline

Modified:
    erp5/trunk/products/ERP5/Document/Url.py

Modified: erp5/trunk/products/ERP5/Document/Url.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Url.py?rev=15893&r1=15892&r2=15893&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Url.py (original)
+++ erp5/trunk/products/ERP5/Document/Url.py Wed Aug 29 11:20:15 2007
@@ -141,20 +141,20 @@
     return ("http://www.erp5.org", "mailto:info at erp5.org")
 
   security.declareProtected(Permissions.UseMailhostServices, 'send')
-  def send(self, from_url=None, to_url=None, msg=None, 
+  def send(self, from_url=None, to_url=None, msg=None,
            subject=None,  attachment_list=None):
     """
     This method was previously named 'SendMail' and is used to send email
-    attachment_list is a list of dictionnary wich has keys :
+
+    * attachment_list is a list of dictionnaries with those keys:
      - name : name of the attachment,
      - content: data of the attachment
-     - mime_type: mime-type corresponding to the attachment     
+     - mime_type: mime-type corresponding to the attachment
     """
     # get the mailhost object
-    try:
-      mailhost=self.getPortalObject().MailHost
-    except:
-      raise AttributeError, "Cannot find a Mail Host object"
+    mailhost = getattr(self.getPortalObject(), 'MailHost', None)
+    if mailhost is None:
+      raise AttributeError, "Cannot find a MailHost object"
     else:
       if from_url is None:
         from_url = self.getUrlString(None)
@@ -194,13 +194,13 @@
 
         # attach it
         if attachment['mime_type'] == 'text/plain':
-          part = MIMEText(attachment['content'], 'utf-8')
+          part = MIMEText(attachment['content'], _charset='utf-8')
         else:
           #  encode non-plaintext attachment in base64
           part = MIMEBase(*attachment['mime_type'].split('/', 1))
           part.set_payload(attachment['content'])
-
-        Encoders.encode_base64(part)
+          Encoders.encode_base64(part)
+
         part.add_header('Content-Disposition', 
                         'attachment; filename=%s' % attachment_name)
         message.attach(part)




More information about the Erp5-report mailing list