Mercurial > p > roundup > code
comparison roundup/mailgw.py @ 4211:61cf00ca920a
Process each message through the mail gateway as a separate transaction.
The mail-gateway used to process messages fetched, e.g., via imap in a
single big transaction. Now we process each message coming in via the
mail-gateway in its own transaction. Regression-tests passed.
See also discussion:
http://thread.gmane.org/gmane.comp.bug-tracking.roundup.user/9500
| author | Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net> |
|---|---|
| date | Tue, 14 Jul 2009 09:10:43 +0000 |
| parents | 0388a5926974 |
| children | d5f67a6eb32e |
comparison
equal
deleted
inserted
replaced
| 4202:e47ec982645b | 4211:61cf00ca920a |
|---|---|
| 522 result = context.op_verify_result() | 522 result = context.op_verify_result() |
| 523 check_pgp_sigs(result.signatures, context, author) | 523 check_pgp_sigs(result.signatures, context, author) |
| 524 | 524 |
| 525 class MailGW: | 525 class MailGW: |
| 526 | 526 |
| 527 def __init__(self, instance, db, arguments=()): | 527 def __init__(self, instance, arguments=()): |
| 528 self.instance = instance | 528 self.instance = instance |
| 529 self.db = db | |
| 530 self.arguments = arguments | 529 self.arguments = arguments |
| 531 self.default_class = None | 530 self.default_class = None |
| 532 for option, value in self.arguments: | 531 for option, value in self.arguments: |
| 533 if option == '-c': | 532 if option == '-c': |
| 534 self.default_class = value.strip() | 533 self.default_class = value.strip() |
| 799 | 798 |
| 800 def handle_message(self, message): | 799 def handle_message(self, message): |
| 801 ''' message - a Message instance | 800 ''' message - a Message instance |
| 802 | 801 |
| 803 Parse the message as per the module docstring. | 802 Parse the message as per the module docstring. |
| 803 ''' | |
| 804 # get database handle for handling one email | |
| 805 self.db = self.instance.open ('admin') | |
| 806 try: | |
| 807 return self._handle_message (message) | |
| 808 finally: | |
| 809 self.db.close() | |
| 810 | |
| 811 def _handle_message(self, message): | |
| 812 ''' message - a Message instance | |
| 813 | |
| 814 Parse the message as per the module docstring. | |
| 815 | |
| 816 The implementation expects an opened database and a try/finally | |
| 817 that closes the database. | |
| 804 ''' | 818 ''' |
| 805 # detect loops | 819 # detect loops |
| 806 if message.getheader('x-roundup-loop', ''): | 820 if message.getheader('x-roundup-loop', ''): |
| 807 raise IgnoreLoop | 821 raise IgnoreLoop |
| 808 | 822 |
