Mercurial > p > roundup > code
annotate roundup/mailgw.py @ 270:a4241ddd22d7
Added the Password property type.
See "pydoc roundup.password" for implementation details. Have updated
some of the documentation too.
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 09 Oct 2001 07:25:59 +0000 |
| parents | a671e5917b33 |
| children | 2313560b8477 |
| rev | line source |
|---|---|
|
213
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
202
diff
changeset
|
1 # |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
202
diff
changeset
|
2 # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/) |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
202
diff
changeset
|
3 # This module is free software, and you may redistribute it and/or modify |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
202
diff
changeset
|
4 # under the same terms as Python, so long as this copyright message and |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
202
diff
changeset
|
5 # disclaimer are retained in their original form. |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
202
diff
changeset
|
6 # |
| 214 | 7 # IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR |
|
213
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
202
diff
changeset
|
8 # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
202
diff
changeset
|
9 # OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
202
diff
changeset
|
10 # POSSIBILITY OF SUCH DAMAGE. |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
202
diff
changeset
|
11 # |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
202
diff
changeset
|
12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
202
diff
changeset
|
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
202
diff
changeset
|
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
202
diff
changeset
|
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
202
diff
changeset
|
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
202
diff
changeset
|
17 # |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
18 ''' |
|
110
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
19 An e-mail gateway for Roundup. |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
20 |
|
110
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
21 Incoming messages are examined for multiple parts: |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
22 . In a multipart/mixed message or part, each subpart is extracted and |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
23 examined. The text/plain subparts are assembled to form the textual |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
24 body of the message, to be stored in the file associated with a "msg" |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
25 class node. Any parts of other types are each stored in separate files |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
26 and given "file" class nodes that are linked to the "msg" node. |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
27 . In a multipart/alternative message or part, we look for a text/plain |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
28 subpart and ignore the other parts. |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
29 |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
30 Summary |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
31 ------- |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
32 The "summary" property on message nodes is taken from the first non-quoting |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
33 section in the message body. The message body is divided into sections by |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
34 blank lines. Sections where the second and all subsequent lines begin with |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
35 a ">" or "|" character are considered "quoting sections". The first line of |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
36 the first non-quoting section becomes the summary of the message. |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
37 |
|
110
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
38 Addresses |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
39 --------- |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
40 All of the addresses in the To: and Cc: headers of the incoming message are |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
41 looked up among the user nodes, and the corresponding users are placed in |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
42 the "recipients" property on the new "msg" node. The address in the From: |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
43 header similarly determines the "author" property of the new "msg" |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
44 node. The default handling for addresses that don't have corresponding |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
45 users is to create new users with no passwords and a username equal to the |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
46 address. (The web interface does not permit logins for users with no |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
47 passwords.) If we prefer to reject mail from outside sources, we can simply |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
48 register an auditor on the "user" class that prevents the creation of user |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
49 nodes with no passwords. |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
50 |
|
110
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
51 Actions |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
52 ------- |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
53 The subject line of the incoming message is examined to determine whether |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
54 the message is an attempt to create a new item or to discuss an existing |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
55 item. A designator enclosed in square brackets is sought as the first thing |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
56 on the subject line (after skipping any "Fwd:" or "Re:" prefixes). |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
57 |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
58 If an item designator (class name and id number) is found there, the newly |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
59 created "msg" node is added to the "messages" property for that item, and |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
60 any new "file" nodes are added to the "files" property for the item. |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
61 |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
62 If just an item class name is found there, we attempt to create a new item |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
63 of that class with its "messages" property initialized to contain the new |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
64 "msg" node and its "files" property initialized to contain any new "file" |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
65 nodes. |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
66 |
|
110
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
67 Triggers |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
68 -------- |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
69 Both cases may trigger detectors (in the first case we are calling the |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
70 set() method to add the message to the item's spool; in the second case we |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
71 are calling the create() method to create a new node). If an auditor raises |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
72 an exception, the original message is bounced back to the sender with the |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
73 explanatory message given in the exception. |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
74 |
|
270
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
75 $Id: mailgw.py,v 1.17 2001-10-09 07:25:59 richard Exp $ |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
76 ''' |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
77 |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
78 |
|
110
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
79 import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
80 import traceback |
|
270
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
81 import hyperdb, date, password |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
82 |
|
221
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
83 class MailUsageError(ValueError): |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
84 pass |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
85 |
|
110
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
86 class Message(mimetools.Message): |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
87 ''' subclass mimetools.Message so we can retrieve the parts of the |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
88 message... |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
89 ''' |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
90 def getPart(self): |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
91 ''' Get a single part of a multipart message and return it as a new |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
92 Message instance. |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
93 ''' |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
94 boundary = self.getparam('boundary') |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
95 mid, end = '--'+boundary, '--'+boundary+'--' |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
96 s = cStringIO.StringIO() |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
97 while 1: |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
98 line = self.fp.readline() |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
99 if not line: |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
100 break |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
101 if line.strip() in (mid, end): |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
102 break |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
103 s.write(line) |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
104 if not s.getvalue().strip(): |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
105 return None |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
106 s.seek(0) |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
107 return Message(s) |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
108 |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
109 subject_re = re.compile(r'(\[?(fwd|re):\s*)*' |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
110 r'(\[(?P<classname>[^\d]+)(?P<nodeid>\d+)?\])' |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
111 r'(?P<title>[^\[]+)(\[(?P<args>.+?)\])?', re.I) |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
112 |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
113 class MailGW: |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
114 def __init__(self, db): |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
115 self.db = db |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
116 |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
117 def main(self, fp): |
|
110
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
118 ''' fp - the file from which to read the Message. |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
119 |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
120 Read a message from fp and then call handle_message() with the |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
121 result. This method's job is to make that call and handle any |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
122 errors in a sane manner. It should be replaced if you wish to |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
123 handle errors in a different manner. |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
124 ''' |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
125 # ok, figure the subject, author, recipients and content-type |
|
110
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
126 message = Message(fp) |
|
221
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
127 m = [] |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
128 try: |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
129 self.handle_message(message) |
|
221
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
130 except MailUsageError, value: |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
131 # bounce the message back to the sender with the usage message |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
132 fulldoc = '\n'.join(string.split(__doc__, '\n')[2:]) |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
133 sendto = [message.getaddrlist('from')[0][1]] |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
134 m = ['Subject: Failed issue tracker submission', ''] |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
135 m.append(str(value)) |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
136 m.append('\nMail Gateway Help\n=================') |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
137 m.append(fulldoc) |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
138 except: |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
139 # bounce the message back to the sender with the error message |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
140 sendto = [message.getaddrlist('from')[0][1]] |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
141 m = ['Subject: failed issue tracker submission'] |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
142 m.append('') |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
143 # TODO as attachments? |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
144 m.append('---- traceback of failure ----') |
|
110
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
145 s = cStringIO.StringIO() |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
146 import traceback |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
147 traceback.print_exc(None, s) |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
148 m.append(s.getvalue()) |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
149 m.append('---- failed message follows ----') |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
150 try: |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
151 fp.seek(0) |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
152 except: |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
153 pass |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
154 m.append(fp.read()) |
|
221
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
155 if m: |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
156 try: |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
157 smtp = smtplib.SMTP(self.MAILHOST) |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
158 smtp.sendmail(self.ADMIN_EMAIL, sendto, '\n'.join(m)) |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
159 except socket.error, value: |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
160 return "Couldn't send confirmation email: mailhost %s"%value |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
161 except smtplib.SMTPException, value: |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
162 return "Couldn't send confirmation email: %s"%value |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
163 |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
164 def handle_message(self, message): |
|
110
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
165 ''' message - a Message instance |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
166 |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
167 Parse the message as per the module docstring. |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
168 ''' |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
169 # handle the subject line |
|
226
8af4945246cb
Make the mail parser a little more robust.
Richard Jones <richard@users.sourceforge.net>
parents:
224
diff
changeset
|
170 subject = message.getheader('subject', '') |
| 218 | 171 m = subject_re.match(subject) |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
172 if not m: |
|
221
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
173 raise MailUsageError, ''' |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
174 The message you sent to roundup did not contain a properly formed subject |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
175 line. The subject must contain a class name or designator to indicate the |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
176 "topic" of the message. For example: |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
177 Subject: [issue] This is a new issue |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
178 - this will create a new issue in the tracker with the title "This is |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
179 a new issue". |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
180 Subject: [issue1234] This is a followup to issue 1234 |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
181 - this will append the message's contents to the existing issue 1234 |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
182 in the tracker. |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
183 |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
184 Subject was: "%s" |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
185 '''%subject |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
186 classname = m.group('classname') |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
187 nodeid = m.group('nodeid') |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
188 title = m.group('title').strip() |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
189 subject_args = m.group('args') |
|
221
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
190 try: |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
191 cl = self.db.getclass(classname) |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
192 except KeyError: |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
193 raise MailUsageError, ''' |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
194 The class name you identified in the subject line ("%s") does not exist in the |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
195 database. |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
196 |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
197 Valid class names are: %s |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
198 Subject was: "%s" |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
199 '''%(classname, ', '.join(self.db.getclasses()), subject) |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
200 properties = cl.getprops() |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
201 props = {} |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
202 args = m.group('args') |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
203 if args: |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
204 for prop in string.split(m.group('args'), ';'): |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
205 try: |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
206 key, value = prop.split('=') |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
207 except ValueError, message: |
|
221
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
208 raise MailUsageError, ''' |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
209 Subject argument list not of form [arg=value,value,...;arg=value,value...] |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
210 (specific exception message was "%s") |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
211 |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
212 Subject was: "%s" |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
213 '''%(message, subject) |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
214 try: |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
215 type = properties[key] |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
216 except KeyError: |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
217 raise MailUsageError, ''' |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
218 Subject argument list refers to an invalid property: "%s" |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
219 |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
220 Subject was: "%s" |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
221 '''%(key, subject) |
|
224
ad2c98faec97
using isinstance(blah, Foo) now instead of isFooType
Richard Jones <richard@users.sourceforge.net>
parents:
221
diff
changeset
|
222 if isinstance(type, hyperdb.String): |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
223 props[key] = value |
|
270
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
224 if isinstance(type, hyperdb.Password): |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
225 props[key] = password.Password(value) |
|
224
ad2c98faec97
using isinstance(blah, Foo) now instead of isFooType
Richard Jones <richard@users.sourceforge.net>
parents:
221
diff
changeset
|
226 elif isinstance(type, hyperdb.Date): |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
227 props[key] = date.Date(value) |
|
224
ad2c98faec97
using isinstance(blah, Foo) now instead of isFooType
Richard Jones <richard@users.sourceforge.net>
parents:
221
diff
changeset
|
228 elif isinstance(type, hyperdb.Interval): |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
229 props[key] = date.Interval(value) |
|
224
ad2c98faec97
using isinstance(blah, Foo) now instead of isFooType
Richard Jones <richard@users.sourceforge.net>
parents:
221
diff
changeset
|
230 elif isinstance(type, hyperdb.Link): |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
231 props[key] = value |
|
224
ad2c98faec97
using isinstance(blah, Foo) now instead of isFooType
Richard Jones <richard@users.sourceforge.net>
parents:
221
diff
changeset
|
232 elif isinstance(type, hyperdb.Multilink): |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
233 props[key] = value.split(',') |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
234 |
|
264
a671e5917b33
Many features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
244
diff
changeset
|
235 # |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
236 # handle the users |
|
264
a671e5917b33
Many features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
244
diff
changeset
|
237 # |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
238 author = self.db.uidFromAddress(message.getaddrlist('from')[0]) |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
239 recipients = [] |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
240 for recipient in message.getaddrlist('to') + message.getaddrlist('cc'): |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
241 if recipient[1].strip().lower() == self.ISSUE_TRACKER_EMAIL: |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
242 continue |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
243 recipients.append(self.db.uidFromAddress(recipient)) |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
244 |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
245 # now handle the body - find the message |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
246 content_type = message.gettype() |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
247 attachments = [] |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
248 if content_type == 'multipart/mixed': |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
249 # skip over the intro to the first boundary |
|
110
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
250 part = message.getPart() |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
251 content = None |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
252 while 1: |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
253 # get the next part |
|
110
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
254 part = message.getPart() |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
255 if part is None: |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
256 break |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
257 # parse it |
|
110
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
258 subtype = part.gettype() |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
259 if subtype == 'text/plain' and not content: |
|
110
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
260 # add all text/plain parts to the message content |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
261 if content is None: |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
262 content = part.fp.read() |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
263 else: |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
264 content = content + part.fp.read() |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
265 |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
266 elif subtype == 'message/rfc822': |
|
110
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
267 # handle message/rfc822 specially - the name should be |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
268 # the subject of the actual e-mail embedded here |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
269 i = part.fp.tell() |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
270 mailmess = Message(part.fp) |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
271 name = mailmess.getheader('subject') |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
272 part.fp.seek(i) |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
273 attachments.append((name, 'message/rfc822', part.fp.read())) |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
274 |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
275 else: |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
276 # try name on Content-Type |
|
110
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
277 name = part.getparam('name') |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
278 # this is just an attachment |
|
110
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
279 data = part.fp.read() |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
280 encoding = part.getencoding() |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
281 if encoding == 'base64': |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
282 data = binascii.a2b_base64(data) |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
283 elif encoding == 'quoted-printable': |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
284 data = quopri.decode(data) |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
285 elif encoding == 'uuencoded': |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
286 data = binascii.a2b_uu(data) |
|
110
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
287 attachments.append((name, part.gettype(), data)) |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
288 |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
289 if content is None: |
|
221
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
290 raise MailUsageError, ''' |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
291 Roundup requires the submission to be plain text. The message parser could |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
292 not find a text/plain part o use. |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
293 ''' |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
294 |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
295 elif content_type[:10] == 'multipart/': |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
296 # skip over the intro to the first boundary |
|
110
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
297 message.getPart() |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
298 content = None |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
299 while 1: |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
300 # get the next part |
|
110
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
301 part = message.getPart() |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
302 if part is None: |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
303 break |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
304 # parse it |
|
110
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
305 if part.gettype() == 'text/plain' and not content: |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
306 # this one's our content |
|
110
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
307 content = part.fp.read() |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
308 if content is None: |
|
221
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
309 raise MailUsageError, ''' |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
310 Roundup requires the submission to be plain text. The message parser could |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
311 not find a text/plain part o use. |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
312 ''' |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
313 |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
314 elif content_type != 'text/plain': |
|
221
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
315 raise MailUsageError, ''' |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
316 Roundup requires the submission to be plain text. The message parser could |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
317 not find a text/plain part o use. |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
318 ''' |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
319 |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
320 else: |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
321 content = message.fp.read() |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
322 |
|
198
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
323 summary, content = parseContent(content) |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
324 |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
325 # handle the files |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
326 files = [] |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
327 for (name, type, data) in attachments: |
|
172
c580555a6508
mailgw was assuming certain properties existed on the issues being created.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
328 files.append(self.db.file.create(type=type, name=name, |
|
c580555a6508
mailgw was assuming certain properties existed on the issues being created.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
329 content=data)) |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
330 |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
331 # now handle the db stuff |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
332 if nodeid: |
|
172
c580555a6508
mailgw was assuming certain properties existed on the issues being created.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
333 # If an item designator (class name and id number) is found there, |
|
c580555a6508
mailgw was assuming certain properties existed on the issues being created.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
334 # the newly created "msg" node is added to the "messages" property |
|
c580555a6508
mailgw was assuming certain properties existed on the issues being created.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
335 # for that item, and any new "file" nodes are added to the "files" |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
336 # property for the item. |
|
172
c580555a6508
mailgw was assuming certain properties existed on the issues being created.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
337 message_id = self.db.msg.create(author=author, |
|
c580555a6508
mailgw was assuming certain properties existed on the issues being created.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
338 recipients=recipients, date=date.Date('.'), summary=summary, |
|
c580555a6508
mailgw was assuming certain properties existed on the issues being created.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
339 content=content, files=files) |
|
221
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
340 try: |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
341 messages = cl.get(nodeid, 'messages') |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
342 except IndexError: |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
343 raise MailUsageError, ''' |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
344 The node specified by the designator in the subject of your message ("%s") |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
345 does not exist. |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
346 |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
347 Subject was: "%s" |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
348 '''%(nodeid, subject) |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
349 messages.append(message_id) |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
350 props['messages'] = messages |
|
172
c580555a6508
mailgw was assuming certain properties existed on the issues being created.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
351 cl.set(nodeid, **props) |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
352 else: |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
353 # If just an item class name is found there, we attempt to create a |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
354 # new item of that class with its "messages" property initialized to |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
355 # contain the new "msg" node and its "files" property initialized to |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
356 # contain any new "file" nodes. |
|
172
c580555a6508
mailgw was assuming certain properties existed on the issues being created.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
357 message_id = self.db.msg.create(author=author, |
|
c580555a6508
mailgw was assuming certain properties existed on the issues being created.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
358 recipients=recipients, date=date.Date('.'), summary=summary, |
|
c580555a6508
mailgw was assuming certain properties existed on the issues being created.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
359 content=content, files=files) |
|
c580555a6508
mailgw was assuming certain properties existed on the issues being created.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
360 # fill out the properties with defaults where required |
|
c580555a6508
mailgw was assuming certain properties existed on the issues being created.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
361 if properties.has_key('assignedto') and \ |
|
c580555a6508
mailgw was assuming certain properties existed on the issues being created.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
362 not props.has_key('assignedto'): |
|
103
381016730332
Fixed some non-string node ids.
Richard Jones <richard@users.sourceforge.net>
parents:
26
diff
changeset
|
363 props['assignedto'] = '1' # "admin" |
|
172
c580555a6508
mailgw was assuming certain properties existed on the issues being created.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
364 if properties.has_key('status') and not props.has_key('status'): |
|
103
381016730332
Fixed some non-string node ids.
Richard Jones <richard@users.sourceforge.net>
parents:
26
diff
changeset
|
365 props['status'] = '1' # "unread" |
|
172
c580555a6508
mailgw was assuming certain properties existed on the issues being created.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
366 if properties.has_key('title') and not props.has_key('title'): |
|
25
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
367 props['title'] = title |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
368 props['messages'] = [message_id] |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
369 props['nosy'] = recipients[:] |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
370 props['nosy'].append(author) |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
371 props['nosy'].sort() |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
372 nodeid = cl.create(**props) |
|
4cf1daf2f2eb
More Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
373 |
|
198
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
374 def parseContent(content, blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'), |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
375 eol=re.compile(r'[\r\n]+'), signature=re.compile(r'^[>|\s]*[-_]+\s*$')): |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
376 ''' The message body is divided into sections by blank lines. |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
377 Sections where the second and all subsequent lines begin with a ">" or "|" |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
378 character are considered "quoting sections". The first line of the first |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
379 non-quoting section becomes the summary of the message. |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
380 ''' |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
381 sections = blank_line.split(content) |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
382 # extract out the summary from the message |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
383 summary = '' |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
384 l = [] |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
385 for section in sections: |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
386 section = section.strip() |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
387 if not section: |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
388 continue |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
389 lines = eol.split(section) |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
390 if lines[0] and lines[0][0] in '>|': |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
391 continue |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
392 if len(lines) > 1 and lines[1] and lines[1][0] in '>|': |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
393 continue |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
394 if not summary: |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
395 summary = lines[0] |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
396 l.append(section) |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
397 continue |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
398 if signature.match(lines[0]): |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
399 break |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
400 l.append(section) |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
401 return summary, '\n'.join(l) |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
402 |
|
26
c7c14960f413
Final commit of Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
25
diff
changeset
|
403 # |
|
c7c14960f413
Final commit of Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
25
diff
changeset
|
404 # $Log: not supported by cvs2svn $ |
|
270
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
405 # Revision 1.16 2001/10/05 02:23:24 richard |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
406 # . roundup-admin create now prompts for property info if none is supplied |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
407 # on the command-line. |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
408 # . hyperdb Class getprops() method may now return only the mutable |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
409 # properties. |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
410 # . Login now uses cookies, which makes it a whole lot more flexible. We can |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
411 # now support anonymous user access (read-only, unless there's an |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
412 # "anonymous" user, in which case write access is permitted). Login |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
413 # handling has been moved into cgi_client.Client.main() |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
414 # . The "extended" schema is now the default in roundup init. |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
415 # . The schemas have had their page headings modified to cope with the new |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
416 # login handling. Existing installations should copy the interfaces.py |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
417 # file from the roundup lib directory to their instance home. |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
418 # . Incorrectly had a Bizar Software copyright on the cgitb.py module from |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
419 # Ping - has been removed. |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
420 # . Fixed a whole bunch of places in the CGI interface where we should have |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
421 # been returning Not Found instead of throwing an exception. |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
422 # . Fixed a deviation from the spec: trying to modify the 'id' property of |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
423 # an item now throws an exception. |
|
a4241ddd22d7
Added the Password property type.
Richard Jones <richard@users.sourceforge.net>
parents:
264
diff
changeset
|
424 # |
|
264
a671e5917b33
Many features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
244
diff
changeset
|
425 # Revision 1.15 2001/08/30 06:01:17 richard |
|
a671e5917b33
Many features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
244
diff
changeset
|
426 # Fixed missing import in mailgw :( |
|
a671e5917b33
Many features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
244
diff
changeset
|
427 # |
|
244
6bf584784e31
Fixed missing import in mailgw :(
Richard Jones <richard@users.sourceforge.net>
parents:
226
diff
changeset
|
428 # Revision 1.14 2001/08/13 23:02:54 richard |
|
6bf584784e31
Fixed missing import in mailgw :(
Richard Jones <richard@users.sourceforge.net>
parents:
226
diff
changeset
|
429 # Make the mail parser a little more robust. |
|
6bf584784e31
Fixed missing import in mailgw :(
Richard Jones <richard@users.sourceforge.net>
parents:
226
diff
changeset
|
430 # |
|
226
8af4945246cb
Make the mail parser a little more robust.
Richard Jones <richard@users.sourceforge.net>
parents:
224
diff
changeset
|
431 # Revision 1.13 2001/08/12 06:32:36 richard |
|
8af4945246cb
Make the mail parser a little more robust.
Richard Jones <richard@users.sourceforge.net>
parents:
224
diff
changeset
|
432 # using isinstance(blah, Foo) now instead of isFooType |
|
8af4945246cb
Make the mail parser a little more robust.
Richard Jones <richard@users.sourceforge.net>
parents:
224
diff
changeset
|
433 # |
|
224
ad2c98faec97
using isinstance(blah, Foo) now instead of isFooType
Richard Jones <richard@users.sourceforge.net>
parents:
221
diff
changeset
|
434 # Revision 1.12 2001/08/08 01:27:00 richard |
|
ad2c98faec97
using isinstance(blah, Foo) now instead of isFooType
Richard Jones <richard@users.sourceforge.net>
parents:
221
diff
changeset
|
435 # Added better error handling to mailgw. |
|
ad2c98faec97
using isinstance(blah, Foo) now instead of isFooType
Richard Jones <richard@users.sourceforge.net>
parents:
221
diff
changeset
|
436 # |
|
221
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
437 # Revision 1.11 2001/08/08 00:08:03 richard |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
438 # oops ;) |
|
152fedaab07c
Added better error handling to mailgw.
Richard Jones <richard@users.sourceforge.net>
parents:
218
diff
changeset
|
439 # |
| 218 | 440 # Revision 1.10 2001/08/07 00:24:42 richard |
| 441 # stupid typo | |
| 442 # | |
| 214 | 443 # Revision 1.9 2001/08/07 00:15:51 richard |
| 444 # Added the copyright/license notice to (nearly) all files at request of | |
| 445 # Bizar Software. | |
| 446 # | |
|
213
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
202
diff
changeset
|
447 # Revision 1.8 2001/08/05 07:06:07 richard |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
202
diff
changeset
|
448 # removed some print statements |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
202
diff
changeset
|
449 # |
|
202
d702ac2ceedb
removed some print statements
Richard Jones <richard@users.sourceforge.net>
parents:
198
diff
changeset
|
450 # Revision 1.7 2001/08/03 07:18:22 richard |
|
d702ac2ceedb
removed some print statements
Richard Jones <richard@users.sourceforge.net>
parents:
198
diff
changeset
|
451 # Implemented correct mail splitting (was taking a shortcut). Added unit |
|
d702ac2ceedb
removed some print statements
Richard Jones <richard@users.sourceforge.net>
parents:
198
diff
changeset
|
452 # tests. Also snips signatures now too. |
|
d702ac2ceedb
removed some print statements
Richard Jones <richard@users.sourceforge.net>
parents:
198
diff
changeset
|
453 # |
|
198
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
454 # Revision 1.6 2001/08/01 04:24:21 richard |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
455 # mailgw was assuming certain properties existed on the issues being created. |
|
eda506860b32
Implemented correct mail splitting (was taking a shortcut).
Richard Jones <richard@users.sourceforge.net>
parents:
172
diff
changeset
|
456 # |
|
172
c580555a6508
mailgw was assuming certain properties existed on the issues being created.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
457 # Revision 1.5 2001/07/29 07:01:39 richard |
|
c580555a6508
mailgw was assuming certain properties existed on the issues being created.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
458 # Added vim command to all source so that we don't get no steenkin' tabs :) |
|
c580555a6508
mailgw was assuming certain properties existed on the issues being created.
Richard Jones <richard@users.sourceforge.net>
parents:
127
diff
changeset
|
459 # |
|
127
0791d13baea7
Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents:
110
diff
changeset
|
460 # Revision 1.4 2001/07/28 06:43:02 richard |
|
0791d13baea7
Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents:
110
diff
changeset
|
461 # Multipart message class has the getPart method now. Added some tests for it. |
|
0791d13baea7
Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents:
110
diff
changeset
|
462 # |
|
110
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
463 # Revision 1.3 2001/07/28 00:34:34 richard |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
464 # Fixed some non-string node ids. |
|
19686b60e410
Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
103
diff
changeset
|
465 # |
|
103
381016730332
Fixed some non-string node ids.
Richard Jones <richard@users.sourceforge.net>
parents:
26
diff
changeset
|
466 # Revision 1.2 2001/07/22 12:09:32 richard |
|
381016730332
Fixed some non-string node ids.
Richard Jones <richard@users.sourceforge.net>
parents:
26
diff
changeset
|
467 # Final commit of Grande Splite |
|
26
c7c14960f413
Final commit of Grande Splite
Richard Jones <richard@users.sourceforge.net>
parents:
25
diff
changeset
|
468 # |
|
103
381016730332
Fixed some non-string node ids.
Richard Jones <richard@users.sourceforge.net>
parents:
26
diff
changeset
|
469 # |
|
127
0791d13baea7
Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents:
110
diff
changeset
|
470 # vim: set filetype=python ts=4 sw=4 et si |
