Barry Warsaw pushed to branch master at mailman / Mailman
Commits: e9ae5574 by Abhilash Raj at 2015-08-03T17:21:22Z Fix #115 - - - - - 7af71bc6 by Abhilash Raj at 2015-08-03T17:21:22Z Add tests for #115 - - - - - ae121d3f by Abhilash Raj at 2015-08-03T17:21:23Z Fix zope lookup error in the previous commit - - - - - 30dd94a3 by Abhilash Raj at 2015-07-31T12:47:43Z Fix #115 - - - - - a965e475 by Abhilash Raj at 2015-07-31T19:53:08Z Add tests for #115 - - - - - 2463db86 by Abhilash Raj at 2015-07-31T20:09:00Z Fix zope lookup error in the previous commit - - - - - d1f06e63 by Abhilash Raj at 2015-08-03T17:24:07Z Merge branch 'issue-115' of gitlab.com:maxking/mailman into issue-115 - - - - - a4bf5b02 by Abhilash Raj at 2015-08-03T18:39:47Z Add tests for autoresponserecord - - - - - ed6088c2 by Barry Warsaw at 2015-08-04T22:24:50Z Clean up maxking's branch a little bit. * Sort the .delete()'s * Remove an unused import. * Renamed and documented some tests. * Support tox's new passenv setting. - - - - - 9855a380 by Barry Warsaw at 2015-08-04T22:27:33Z Add NEWS. - - - - - e64ee63b by Barry Warsaw at 2015-08-04T22:28:57Z Merge branch 'maxking/mailman-issue-115' Fix constraint violations on mailing list deletes affecting PostgreSQL. Given by Abhilash Raj. (Closes #115) - - - - - 4 changed files: - src/mailman/docs/NEWS.rst - src/mailman/model/listmanager.py - src/mailman/model/tests/test_listmanager.py - tox.ini Changes: ===================================== src/mailman/docs/NEWS.rst ===================================== --- a/src/mailman/docs/NEWS.rst +++ b/src/mailman/docs/NEWS.rst @@ -24,6 +24,8 @@ Bugs variable `[mailman]html_to_plain_text_command` in the `mailman.cfg` file defines the command to use. It defaults to `lynx`. (Closes: #109) * Confirmation messages should not be `Precedence: bulk`. (Closes #75) + * Fix constraint violations on mailing list deletes affecting PostgreSQL. + Given by Abhilash Raj. (Closes #115) Configuration ------------- ===================================== src/mailman/model/listmanager.py ===================================== --- a/src/mailman/model/listmanager.py +++ b/src/mailman/model/listmanager.py @@ -27,7 +27,9 @@ from mailman.interfaces.address import InvalidEmailAddressError from mailman.interfaces.listmanager import ( IListManager, ListAlreadyExistsError, ListCreatedEvent, ListCreatingEvent, ListDeletedEvent, ListDeletingEvent) -from mailman.model.mailinglist import IAcceptableAliasSet, MailingList +from mailman.model.autorespond import AutoResponseRecord +from mailman.model.mailinglist import ( + IAcceptableAliasSet, ListArchiver, MailingList) from mailman.model.mime import ContentFilter from mailman.utilities.datetime import now from zope.event import notify @@ -76,7 +78,9 @@ class ListManager: notify(ListDeletingEvent(mlist)) # First delete information associated with the mailing list. IAcceptableAliasSet(mlist).clear() + store.query(AutoResponseRecord).filter_by(mailing_list=mlist).delete() store.query(ContentFilter).filter_by(mailing_list=mlist).delete() + store.query(ListArchiver).filter_by(mailing_list=mlist).delete() store.delete(mlist) notify(ListDeletedEvent(fqdn_listname)) ===================================== src/mailman/model/tests/test_listmanager.py ===================================== --- a/src/mailman/model/tests/test_listmanager.py +++ b/src/mailman/model/tests/test_listmanager.py @@ -29,10 +29,12 @@ import unittest from mailman.app.lifecycle import create_list from mailman.app.moderator import hold_message from mailman.config import config +from mailman.interfaces.autorespond import IAutoResponseSet, Response from mailman.interfaces.address import InvalidEmailAddressError from mailman.interfaces.listmanager import ( IListManager, ListAlreadyExistsError, ListCreatedEvent, ListCreatingEvent, ListDeletedEvent, ListDeletingEvent) +from mailman.interfaces.mailinglist import IListArchiverSet from mailman.interfaces.messages import IMessageStore from mailman.interfaces.requests import IListRequests from mailman.interfaces.subscriptions import ISubscriptionService @@ -86,6 +88,29 @@ class TestListManager(unittest.TestCase): sorted(getUtility(IListManager).list_ids), ['ant.example.com', 'bee.example.com', 'cat.example.com']) + def test_delete_list_with_list_archiver_set(self): + # Ensure that mailing lists with archiver sets can be deleted. In + # issue #115, this fails under PostgreSQL, but not SQLite. + mlist = create_list('a...@example.com') + # We don't keep a reference to this archiver set just because it makes + # pyflakes unhappy. It doesn't change the outcome. + IListArchiverSet(mlist) + list_manager = getUtility(IListManager) + list_manager.delete(mlist) + self.assertIsNone(list_manager.get('a...@example.com')) + + def test_delete_list_with_autoresponse_record(self): + # Ensure that mailing lists with auto-response sets can be deleted. In + # issue #115, this fails under PostgreSQL, but not SQLite. + list_manager = getUtility(IListManager) + user_manager = getUtility(IUserManager) + mlist = create_list('a...@example.com') + address = user_manager.create_address('aper...@example.com') + autoresponse_set = IAutoResponseSet(mlist) + autoresponse_set.response_sent(address, Response.hold) + list_manager.delete(mlist) + self.assertIsNone(list_manager.get('a...@example.com')) + class TestListLifecycleEvents(unittest.TestCase): ===================================== tox.ini ===================================== --- a/tox.ini +++ b/tox.ini @@ -6,6 +6,8 @@ recreate = True commands = python -m nose2 -v #sitepackages = True usedevelop = True +passenv= + MAILMAN_* # This environment requires you to set up PostgreSQL and create a .cfg file # somewhere outside of the source tree. View it on GitLab: https://gitlab.com/mailman/mailman/compare/d42dd4a73228eab1309e517695866ac7debbba23...e64ee63b97decf8223a96bbc834a438e4d4fda58
_______________________________________________ Mailman-checkins mailing list Mailman-checkins@python.org Unsubscribe: https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org