1515# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717#
18- # $Id: roundupdb.py,v 1.86.2.2 2004-02-23 05:37:11 richard Exp $
18+ # $Id: roundupdb.py,v 1.86.2.3 2004-02-28 22:53:16 richard Exp $
1919
2020__doc__ = """
2121Extending hyperdb with types specific to issue-tracking.
@@ -209,9 +209,15 @@ def send_message(self, nodeid, msgid, note, sendto, from_address=None):
209209 self .classname , nodeid , self .db .config .MAIL_DOMAIN )
210210 messages .set (msgid , messageid = messageid )
211211
212- # send an email to the people who missed out
212+ # character set to encode the email with
213+ charset = getattr (self .db .config , 'EMAIL_CHARSET' , 'utf-8' )
214+
215+ # title for the message
213216 cn = self .classname
214217 title = self .get (nodeid , 'title' ) or '%s message copy' % cn
218+ if charset != 'utf-8' :
219+ title = unicode (title , 'utf-8' ).encode (charset )
220+
215221 # figure author information
216222 authid = messages .get (msgid , 'author' )
217223 authname = users .get (authid , 'realname' )
@@ -249,7 +255,10 @@ def send_message(self, nodeid, msgid, note, sendto, from_address=None):
249255 m .append (self .email_signature (nodeid , msgid ))
250256
251257 # encode the content as quoted-printable
252- content = cStringIO .StringIO ('\n ' .join (m ))
258+ m = '\n ' .join (m )
259+ if charset != 'utf-8' :
260+ m = unicode (m , 'utf-8' ).encode (charset )
261+ content = cStringIO .StringIO (m )
253262 content_encoded = cStringIO .StringIO ()
254263 quopri .encode (content , content_encoded , 0 )
255264 content_encoded = content_encoded .getvalue ()
@@ -273,12 +282,11 @@ def send_message(self, nodeid, msgid, note, sendto, from_address=None):
273282 message = cStringIO .StringIO ()
274283 writer = MimeWriter .MimeWriter (message )
275284 writer .addheader ('Subject' , '[%s%s] %s' % (cn , nodeid ,
276- encode_header (title , self . db . config . EMAIL_CHARSET )))
285+ encode_header (title , charset )))
277286 writer .addheader ('To' , ', ' .join (sendto ))
278- writer .addheader ('From' , straddr ((encode_header (authname ,
279- self .db .config .EMAIL_CHARSET ) + from_tag , from_address )))
280- tracker_name = encode_header (self .db .config .TRACKER_NAME ,
281- self .db .config .EMAIL_CHARSET )
287+ writer .addheader ('From' , straddr ((encode_header (authname , charset )
288+ + from_tag , from_address )))
289+ tracker_name = encode_header (self .db .config .TRACKER_NAME , charset )
282290 writer .addheader ('Reply-To' , straddr ((tracker_name , from_address )))
283291 writer .addheader ('Date' , time .strftime ("%a, %d %b %Y %H:%M:%S +0000" ,
284292 time .gmtime ()))
@@ -299,7 +307,7 @@ def send_message(self, nodeid, msgid, note, sendto, from_address=None):
299307 part = writer .startmultipartbody ('mixed' )
300308 part = writer .nextpart ()
301309 part .addheader ('Content-Transfer-Encoding' , 'quoted-printable' )
302- body = part .startbody ('text/plain; charset=utf-8' )
310+ body = part .startbody ('text/plain; charset=%s' % charset )
303311 body .write (content_encoded )
304312 for fileid in message_files :
305313 name = files .get (fileid , 'name' )
@@ -327,7 +335,7 @@ def send_message(self, nodeid, msgid, note, sendto, from_address=None):
327335 writer .lastpart ()
328336 else :
329337 writer .addheader ('Content-Transfer-Encoding' , 'quoted-printable' )
330- body = writer .startbody ('text/plain; charset=utf-8' )
338+ body = writer .startbody ('text/plain; charset=%s' % charset )
331339 body .write (content_encoded )
332340
333341 # now try to send the message
0 commit comments