summaryrefslogtreecommitdiff
path: root/src/mailman/model
diff options
context:
space:
mode:
authorBarry Warsaw2013-10-24 20:38:39 -0400
committerBarry Warsaw2013-10-24 20:38:39 -0400
commitb4d3a036b5949c6945b13416615cfd356a327ee2 (patch)
tree005fb17df2571caba1a706e4ffd30511083e633b /src/mailman/model
parentd370397e38f6357612811ba55af7fdee4552b59e (diff)
parentb36b316a74cf06affbd709b3a3f3a3cfac6921c0 (diff)
downloadmailman-b4d3a036b5949c6945b13416615cfd356a327ee2.tar.gz
mailman-b4d3a036b5949c6945b13416615cfd356a327ee2.tar.zst
mailman-b4d3a036b5949c6945b13416615cfd356a327ee2.zip
* The `bounceevent` table now uses list-ids to cross-reference the mailing
list, to match other tables. Similarly for the `IBounceEvent` interface. Also: - Move the acquisition of the database lock during creation to the IDatabaseFactory.create() method instead of the individual database initialize() methods. - In the migration.rst doctest, don't delete teh version records when using SQLite, since that breaks tests. - Implement a few nice helpers for database migrations, including make_listid() for turning a list name into a list id, and pivot() which simplifies moving the backup table to the final table name.
Diffstat (limited to 'src/mailman/model')
-rw-r--r--src/mailman/model/bounce.py8
-rw-r--r--src/mailman/model/docs/bounce.rst4
-rw-r--r--src/mailman/model/tests/test_bounce.py4
3 files changed, 8 insertions, 8 deletions
diff --git a/src/mailman/model/bounce.py b/src/mailman/model/bounce.py
index 47a6ed248..9ae2b585d 100644
--- a/src/mailman/model/bounce.py
+++ b/src/mailman/model/bounce.py
@@ -43,15 +43,15 @@ class BounceEvent(Model):
"""See `IBounceEvent`."""
id = Int(primary=True)
- list_name = Unicode()
+ list_id = Unicode()
email = Unicode()
timestamp = DateTime()
message_id = Unicode()
context = Enum(BounceContext)
processed = Bool()
- def __init__(self, list_name, email, msg, context=None):
- self.list_name = list_name
+ def __init__(self, list_id, email, msg, context=None):
+ self.list_id = list_id
self.email = email
self.timestamp = now()
self.message_id = msg['message-id']
@@ -67,7 +67,7 @@ class BounceProcessor:
@dbconnection
def register(self, store, mlist, email, msg, where=None):
"""See `IBounceProcessor`."""
- event = BounceEvent(mlist.fqdn_listname, email, msg, where)
+ event = BounceEvent(mlist.list_id, email, msg, where)
store.add(event)
return event
diff --git a/src/mailman/model/docs/bounce.rst b/src/mailman/model/docs/bounce.rst
index b1491e607..f427689bd 100644
--- a/src/mailman/model/docs/bounce.rst
+++ b/src/mailman/model/docs/bounce.rst
@@ -39,8 +39,8 @@ of bouncing email addresses. These are passed one-by-one to the registration
interface.
>>> event = processor.register(mlist, 'anne@example.com', msg)
- >>> print event.list_name
- test@example.com
+ >>> print event.list_id
+ test.example.com
>>> print event.email
anne@example.com
>>> print event.message_id
diff --git a/src/mailman/model/tests/test_bounce.py b/src/mailman/model/tests/test_bounce.py
index 0657c78f3..ad3467d11 100644
--- a/src/mailman/model/tests/test_bounce.py
+++ b/src/mailman/model/tests/test_bounce.py
@@ -58,7 +58,7 @@ Message-Id: <first>
events = list(self._processor.events)
self.assertEqual(len(events), 1)
event = events[0]
- self.assertEqual(event.list_name, 'test@example.com')
+ self.assertEqual(event.list_id, 'test.example.com')
self.assertEqual(event.email, 'anne@example.com')
self.assertEqual(event.timestamp, datetime(2005, 8, 1, 7, 49, 23))
self.assertEqual(event.message_id, '<first>')
@@ -68,7 +68,7 @@ Message-Id: <first>
unprocessed = list(self._processor.unprocessed)
self.assertEqual(len(unprocessed), 1)
event = unprocessed[0]
- self.assertEqual(event.list_name, 'test@example.com')
+ self.assertEqual(event.list_id, 'test.example.com')
self.assertEqual(event.email, 'anne@example.com')
self.assertEqual(event.timestamp, datetime(2005, 8, 1, 7, 49, 23))
self.assertEqual(event.message_id, '<first>')