Changeset 143:1d4505cef74f

Show
Ignore:
Timestamp:
07/31/07 17:15:58 (13 months ago)
Author:
Tarek Ziad?? <tarek@…>
Message:

fixed mail headers

Files:
3 modified

Legend:

Unmodified
Added
Removed
  • mailer/mailer.py

    r137 r143  
    4747    def _get_message(self, mail): 
    4848        """returns a Mime""" 
    49         msg = MIMEText(b64decode(mail.data)) 
     49        data = b64decode(mail.data) 
     50        # some sgbd are in unicode 
     51        if isinstance(data, unicode): 
     52            data = data.decode('utf8') 
     53        msg = MIMEText(data) 
    5054        msg['From'] = mail.sender 
    5155        msg['To'] = mail.recipients 
    5256        msg['Subject'] = mail.subject 
    53  
    54         msg['Date'] = mail.date.isoformat() 
     57        msg.set_charset('utf-8') 
     58        msg['Date'] = mail.date.strftime('%c') 
    5559        return msg 
    5660 
  • mailer/tests/test_mailer.py

    r136 r143  
    4545 
    4646        worker = MailWorker() 
    47         mail_id = send_mail('toto', 'toto@toto.com', 
    48                             'vouvou', 'coucou') 
     47        mail_id = send_mail('toto', ['toto@toto.com'], 
     48                            'vouvou', 'coucou Ã©') 
    4949 
    5050        mail = worker._get_mails()[0] 
    5151        msg = worker._get_message(mail) 
     52        raw = """\ 
     53MIME-Version: 1.0 
     54Content-Transfer-Encoding: 8bit 
     55From: toto 
     56To: toto@toto.com 
     57Subject: vouvou 
     58Content-Type: text/plain; charset="utf-8" 
     59 
     60coucou \xc3\xa9""" 
     61 
     62        msg = msg.as_string().split('\n') 
     63        msg = [line for line in msg if not line.startswith('Date')] 
     64        msg = '\n'.join(msg) 
     65 
     66        self.assertEquals(msg, raw) 
     67 
    5268 
    5369def test_suite(): 
  • xap/xapindexer.py

    r119 r143  
    5656    def index_document(self, uid, text): 
    5757        """indexes the given document""" 
     58 
    5859        logging.debug('xap:indexing %s' % uid) 
    5960        words = tokenize([text], options={'treshold': 2})