rpms/roundup/F-11 import.log, NONE, 1.1 roundup--mailer.diff, NONE, 1.1 roundup.spec, 1.19, 1.20

John A. Khvatov ivaxer at fedoraproject.org
Fri Feb 12 19:05:38 UTC 2010


Author: ivaxer

Update of /cvs/pkgs/rpms/roundup/F-11
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv9488/F-11

Modified Files:
	roundup.spec 
Added Files:
	import.log roundup--mailer.diff 
Log Message:
- updated mailer.py from upstream



--- NEW FILE import.log ---
roundup-1_4_10-2_fc12:F-11:roundup-1.4.10-2.fc12.src.rpm:1266001503

roundup--mailer.diff:
 mailer.py |   42 ++++++++++++++++++++++++++++++++----------
 1 file changed, 32 insertions(+), 10 deletions(-)

--- NEW FILE roundup--mailer.diff ---
diff --git a/roundup/mailer.py b/roundup/mailer.py
index 171ec11..d44568e 100644
--- a/roundup/mailer.py
+++ b/roundup/mailer.py
@@ -9,7 +9,7 @@ from cStringIO import StringIO
 from roundup import __version__
 from roundup.date import get_timezone
 
-from email.Utils import formatdate, formataddr
+from email.Utils import formatdate, formataddr, specialsre, escapesre
 from email.Message import Message
 from email.Header import Header
 from email.MIMEText import MIMEText
@@ -25,6 +25,25 @@ def encode_quopri(msg):
     del msg['Content-Transfer-Encoding']
     msg['Content-Transfer-Encoding'] = 'quoted-printable'
 
+def nice_sender_header(name, address, charset):
+    # construct an address header so it's as human-readable as possible
+    # even in the presence of a non-ASCII name part
+    if not name:
+        return address
+    try:
+        encname = name.encode('ASCII')
+    except UnicodeEncodeError:
+        # use Header to encode correctly.
+        encname = Header(name, charset=charset).encode()
+
+    # the important bits of formataddr()
+    if specialsre.search(encname):
+        encname = '"%s"'%escapesre.sub(r'\\\g<0>', encname)
+
+    # now format the header as a string - don't return a Header as anonymous
+    # headers play poorly with Messages (eg. won't get wrapped properly)
+    return '%s <%s>'%(encname, address)
+
 class Mailer:
     """Roundup-specific mail sending."""
     def __init__(self, config):
@@ -61,10 +80,11 @@ class Mailer:
         charset = getattr(self.config, 'EMAIL_CHARSET', 'utf-8')
         tracker_name = unicode(self.config.TRACKER_NAME, 'utf-8')
         if not author:
-            author = formataddr((tracker_name, self.config.ADMIN_EMAIL))
+            author = (tracker_name, self.config.ADMIN_EMAIL)
+            name = author[0]
         else:
             name = unicode(author[0], 'utf-8')
-            author = formataddr((name, author[1]))
+        author = nice_sender_header(name, author[1], charset)
 
         if multipart:
             message = MIMEMultipart()
@@ -77,10 +97,7 @@ class Mailer:
         except UnicodeError:
             message['Subject'] = Header(subject, charset)
         message['To'] = ', '.join(to)
-        try:
-            message['From'] = author.encode('ascii')
-        except UnicodeError:
-            message['From'] = Header(author, charset)
+        message['From'] = author
         message['Date'] = formatdate(localtime=True)
 
         # add a Precedence header so autoresponders ignore us
@@ -177,17 +194,22 @@ class Mailer:
         content = '\n'.join(traceback.format_exception(*sys.exc_info()))
         self.standard_message(to, subject, content)
 
-    def smtp_send(self, to, message):
+    def smtp_send(self, to, message, sender=None):
         """Send a message over SMTP, using roundup's config.
 
         Arguments:
         - to: a list of addresses usable by rfc822.parseaddr().
         - message: a StringIO instance with a full message.
+        - sender: if not 'None', the email address to use as the
+        envelope sender.  If 'None', the admin email is used.
         """
+
+        if not sender:
+            sender = self.config.ADMIN_EMAIL
         if self.debug:
             # don't send - just write to a file
             open(self.debug, 'a').write('FROM: %s\nTO: %s\n%s\n' %
-                                        (self.config.ADMIN_EMAIL,
+                                        (sender,
                                          ', '.join(to), message))
         else:
             # now try to send the message
@@ -195,7 +217,7 @@ class Mailer:
                 # send the message as admin so bounces are sent there
                 # instead of to roundup
                 smtp = SMTPConnection(self.config)
-                smtp.sendmail(self.config.ADMIN_EMAIL, to, message)
+                smtp.sendmail(sender, to, message)
             except socket.error, value:
                 raise MessageSendError("Error: couldn't send email: "
                                        "mailhost %s"%value)


Index: roundup.spec
===================================================================
RCS file: /cvs/pkgs/rpms/roundup/F-11/roundup.spec,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -p -r1.19 -r1.20
--- roundup.spec	18 Oct 2009 18:39:23 -0000	1.19
+++ roundup.spec	12 Feb 2010 19:05:38 -0000	1.20
@@ -3,13 +3,14 @@
 Summary: Simple and flexible issue-tracking system
 Name: roundup
 Version: 1.4.10
-Release: 1%{dist}
+Release: 2%{dist}
 License: MIT
 Group: Applications/Engineering
 Source: http://pypi.python.org/packages/source/r/%{name}/%{name}-%{version}.tar.gz
 Source1: roundup.conf
 Source2: roundup
 Source3: README.Fedora
+Patch1: roundup--mailer.diff
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildArch: noarch
 BuildRequires: python-devel
@@ -27,6 +28,7 @@ Yee in the Software Carpentry "Track" de
 
 %prep
 %setup -q
+%patch1 -p1
 
 mv locale/ru.po locale/ru-koi8.po
 iconv -f koi8-r -t utf-8 locale/ru-koi8.po | sed -e 's|Content-Type: text/plain; charset=koi8-r|Content-Type: text/plain; charset=utf-8|' > locale/ru.po
@@ -79,6 +81,9 @@ rm -rf $RPM_BUILD_ROOT
 %doc README.Fedora COPYING.txt
 
 %changelog
+* Fri Feb 12 2010 John Khvatov <ivaxer at fedoraproject.org> - 1.4.10-2
+- updated mailer.py from upstream
+
 * Sun Oct 18 2009 Paul P. Komkoff Jr <i at stingr.net> - 1.4.10-1
 - new upstream version
 



More information about the scm-commits mailing list