Mercurial > p > roundup > code
diff 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 |
line wrap: on
line diff
--- a/roundup/mailgw.py Mon Jul 13 16:00:35 2009 +0000 +++ b/roundup/mailgw.py Tue Jul 14 09:10:43 2009 +0000 @@ -524,9 +524,8 @@ class MailGW: - def __init__(self, instance, db, arguments=()): + def __init__(self, instance, arguments=()): self.instance = instance - self.db = db self.arguments = arguments self.default_class = None for option, value in self.arguments: @@ -802,6 +801,21 @@ Parse the message as per the module docstring. ''' + # get database handle for handling one email + self.db = self.instance.open ('admin') + try: + return self._handle_message (message) + finally: + self.db.close() + + def _handle_message(self, message): + ''' message - a Message instance + + Parse the message as per the module docstring. + + The implementation expects an opened database and a try/finally + that closes the database. + ''' # detect loops if message.getheader('x-roundup-loop', ''): raise IgnoreLoop
