Changeset 143:1d4505cef74f
- Timestamp:
- 07/31/07 17:15:58 (13 months ago)
- Author:
- Tarek Ziad?? <tarek@…>
- Message:
-
fixed mail headers
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r137
|
r143
|
|
| 47 | 47 | def _get_message(self, mail): |
| 48 | 48 | """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) |
| 50 | 54 | msg['From'] = mail.sender |
| 51 | 55 | msg['To'] = mail.recipients |
| 52 | 56 | msg['Subject'] = mail.subject |
| 53 | | |
| 54 | | msg['Date'] = mail.date.isoformat() |
| | 57 | msg.set_charset('utf-8') |
| | 58 | msg['Date'] = mail.date.strftime('%c') |
| 55 | 59 | return msg |
| 56 | 60 | |
-
|
r136
|
r143
|
|
| 45 | 45 | |
| 46 | 46 | 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 é') |
| 49 | 49 | |
| 50 | 50 | mail = worker._get_mails()[0] |
| 51 | 51 | msg = worker._get_message(mail) |
| | 52 | raw = """\ |
| | 53 | MIME-Version: 1.0 |
| | 54 | Content-Transfer-Encoding: 8bit |
| | 55 | From: toto |
| | 56 | To: toto@toto.com |
| | 57 | Subject: vouvou |
| | 58 | Content-Type: text/plain; charset="utf-8" |
| | 59 | |
| | 60 | coucou \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 | |
| 52 | 68 | |
| 53 | 69 | def test_suite(): |
-
|
r119
|
r143
|
|
| 56 | 56 | def index_document(self, uid, text): |
| 57 | 57 | """indexes the given document""" |
| | 58 | |
| 58 | 59 | logging.debug('xap:indexing %s' % uid) |
| 59 | 60 | words = tokenize([text], options={'treshold': 2}) |