Ticket #79: author_revert_79

File author_revert_79, 3.3 kB (added by fs, 4 months ago)

I decided to use 'from_' as parameter because this does really is the closest to the rfc822 header field and 'from' is a reserved word in Python.

Line 
1diff -r b9c4a5d8918b tests/test_message.py
2--- a/tests/test_message.py     Sun Jul 13 17:50:14 2008 +0200
3+++ b/tests/test_message.py     Sun Jul 13 19:05:22 2008 +0200
4@@ -22,15 +22,15 @@
5 
6     def setUp(self):
7         self.message = Message(
8-                author=("Author", "author@example.com"),
9+                from_=("Author", "author@example.com"),
10                 to=("Recipient", "recipient@example.com"),
11                 subject="Test message subject.",
12                 plain="This is a test message plain text body."
13             )
14     
15     def test_message_properties(self):
16-        self.assertEqual(self.message.author, [("Author", "author@example.com")])
17-        self.assertEqual(str(self.message.author), "Author <author@example.com>")
18+        self.assertEqual(self.message.from_, [("Author", "author@example.com")])
19+        self.assertEqual(str(self.message.from_), "Author <author@example.com>")
20         self.failUnless(isinstance(self.message.mime, MIMEText))
21     
22     def test_message_string(self):
23@@ -62,7 +62,7 @@
24         from_name = u"Karl MÃŒller"
25         from_email = u"karl.mueller@mueller.com"
26         
27-        self.message.author = [(from_name, from_email)]
28+        self.message.from_ = [(from_name, from_email)]
29         self.message.encoding = "ISO-8859-1"
30         
31         msg_string = str(self.message)
32diff -r b9c4a5d8918b turbomail/message.py
33--- a/turbomail/message.py      Sun Jul 13 17:50:14 2008 +0200
34+++ b/turbomail/message.py      Sun Jul 13 19:05:22 2008 +0200
35@@ -67,7 +67,7 @@
36         if 'authors' in kw: kw['author'] == kw['authors']
37         if 'senders' in kw: kw['sender'] == kw['senders']
38         
39-        self._author = AddressList(configget("author", "mail.message.author"))
40+        self._from = AddressList(configget("from_", "mail.message.author"))
41         self._sender = AddressList(configget("sender", "mail.message.sender"))
42         self._reply = AddressList(configget("reply", "mail.message.reply"))
43         self._to = AddressList(kw.get("to", None))
44@@ -98,7 +98,7 @@
45     def __str__(self):
46         return self.mime.as_string()
47     
48-    author = AddressList.protected('_author')
49+    from_ = AddressList.protected('_from')
50     authors = AddressList.protected('_author')
51     sender = AddressList.protected('_sender')
52     senders = AddressList.protected('_sender')
53@@ -119,7 +119,7 @@
54     id = property(id)
55     
56     def envelope(self):
57-        if self.sender and self.senders != self.author:
58+        if self.sender and self.senders != self.from_:
59             return AddressList(self.sender)
60         return AddressList(self.author)
61     
62@@ -158,7 +158,7 @@
63     def mime(self):
64         """Produce the final MIME message."""
65 
66-        assert self.author, "You must specify an author."
67+        assert self.from_, "You must specify an author."
68         assert self.subject, "You must specify a subject."
69         assert self.to or self.cc or self.bcc, "You must specify at least one recipient."
70         assert self.plain, "You must provide plain text content."
71@@ -178,7 +178,7 @@
72         
73         headers = [
74                 ('Sender', self.sender),
75-                ('From', self.author),
76+                ('From', self.from_),
77                 ('Reply-To', self.reply),
78                 ('Subject', self.subject),
79                 ('Date', self.date),