Mercurial > p > roundup > code
comparison roundup/mailgw.py @ 824:34eacaa7e313
Added ability for unit tests to turn off exception handling in mailgw so
that exceptions are reported earlier (and hence make sense).
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 09 Jul 2002 01:21:24 +0000 |
| parents | 938edfdeac6e |
| children | 0f0f6049c9a7 |
comparison
equal
deleted
inserted
replaced
| 823:57f19823635b | 824:34eacaa7e313 |
|---|---|
| 71 set() method to add the message to the item's spool; in the second case we | 71 set() method to add the message to the item's spool; in the second case we |
| 72 are calling the create() method to create a new node). If an auditor raises | 72 are calling the create() method to create a new node). If an auditor raises |
| 73 an exception, the original message is bounced back to the sender with the | 73 an exception, the original message is bounced back to the sender with the |
| 74 explanatory message given in the exception. | 74 explanatory message given in the exception. |
| 75 | 75 |
| 76 $Id: mailgw.py,v 1.74 2002-05-29 01:16:17 richard Exp $ | 76 $Id: mailgw.py,v 1.75 2002-07-09 01:21:24 richard Exp $ |
| 77 ''' | 77 ''' |
| 78 | 78 |
| 79 | 79 |
| 80 import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri | 80 import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri |
| 81 import time, random | 81 import time, random |
| 126 class MailGW: | 126 class MailGW: |
| 127 def __init__(self, instance, db): | 127 def __init__(self, instance, db): |
| 128 self.instance = instance | 128 self.instance = instance |
| 129 self.db = db | 129 self.db = db |
| 130 | 130 |
| 131 # should we trap exceptions (normal usage) or pass them through | |
| 132 # (for testing) | |
| 133 self.trapExceptions = 1 | |
| 134 | |
| 131 def main(self, fp): | 135 def main(self, fp): |
| 132 ''' fp - the file from which to read the Message. | 136 ''' fp - the file from which to read the Message. |
| 133 ''' | 137 ''' |
| 134 return self.handle_Message(Message(fp)) | 138 return self.handle_Message(Message(fp)) |
| 135 | 139 |
| 144 ''' | 148 ''' |
| 145 # in some rare cases, a particularly stuffed-up e-mail will make | 149 # in some rare cases, a particularly stuffed-up e-mail will make |
| 146 # its way into here... try to handle it gracefully | 150 # its way into here... try to handle it gracefully |
| 147 sendto = message.getaddrlist('from') | 151 sendto = message.getaddrlist('from') |
| 148 if sendto: | 152 if sendto: |
| 153 if not self.trapExceptions: | |
| 154 return self.handle_message(message) | |
| 149 try: | 155 try: |
| 150 return self.handle_message(message) | 156 return self.handle_message(message) |
| 151 except MailUsageHelp: | 157 except MailUsageHelp: |
| 152 # bounce the message back to the sender with the usage message | 158 # bounce the message back to the sender with the usage message |
| 153 fulldoc = '\n'.join(string.split(__doc__, '\n')[2:]) | 159 fulldoc = '\n'.join(string.split(__doc__, '\n')[2:]) |
| 763 content = '\n\n'.join(l) | 769 content = '\n\n'.join(l) |
| 764 return summary, content | 770 return summary, content |
| 765 | 771 |
| 766 # | 772 # |
| 767 # $Log: not supported by cvs2svn $ | 773 # $Log: not supported by cvs2svn $ |
| 774 # Revision 1.74 2002/05/29 01:16:17 richard | |
| 775 # Sorry about this huge checkin! It's fixing a lot of related stuff in one go | |
| 776 # though. | |
| 777 # | |
| 778 # . #541941 ] changing multilink properties by mail | |
| 779 # . #526730 ] search for messages capability | |
| 780 # . #505180 ] split MailGW.handle_Message | |
| 781 # - also changed cgi client since it was duplicating the functionality | |
| 782 # . build htmlbase if tests are run using CVS checkout (removed note from | |
| 783 # installation.txt) | |
| 784 # . don't create an empty message on email issue creation if the email is empty | |
| 785 # | |
| 768 # Revision 1.73 2002/05/22 04:12:05 richard | 786 # Revision 1.73 2002/05/22 04:12:05 richard |
| 769 # . applied patch #558876 ] cgi client customization | 787 # . applied patch #558876 ] cgi client customization |
| 770 # ... with significant additions and modifications ;) | 788 # ... with significant additions and modifications ;) |
| 771 # - extended handling of ML assignedto to all places it's handled | 789 # - extended handling of ML assignedto to all places it's handled |
| 772 # - added more NotFound info | 790 # - added more NotFound info |
