diff options
| author | Barry Warsaw | 2012-04-08 19:40:38 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2012-04-08 19:40:38 -0400 |
| commit | fdfc98239de2cfdfff6c62a5bb9d49abc8d3722e (patch) | |
| tree | 15944f47693c8dbf3fd80292112d5f9d1ccac4d5 /src | |
| parent | 2410fe8c2578fbd11275cfc7fc1897173eecd41a (diff) | |
| download | mailman-fdfc98239de2cfdfff6c62a5bb9d49abc8d3722e.tar.gz mailman-fdfc98239de2cfdfff6c62a5bb9d49abc8d3722e.tar.zst mailman-fdfc98239de2cfdfff6c62a5bb9d49abc8d3722e.zip | |
Diffstat (limited to 'src')
| -rw-r--r-- | src/mailman/database/schema/mm_20120407000000.py | 14 | ||||
| -rw-r--r-- | src/mailman/database/schema/sqlite_20120407000000_01.sql | 5 | ||||
| -rw-r--r-- | src/mailman/database/tests/test_migrations.py | 10 | ||||
| -rw-r--r-- | src/mailman/interfaces/mailinglist.py | 10 | ||||
| -rw-r--r-- | src/mailman/interfaces/nntp.py | 4 | ||||
| -rw-r--r-- | src/mailman/model/mailinglist.py | 12 | ||||
| -rw-r--r-- | src/mailman/rules/docs/news-moderation.rst | 6 | ||||
| -rw-r--r-- | src/mailman/rules/news_moderation.py | 4 | ||||
| -rw-r--r-- | src/mailman/runners/nntp.py | 10 | ||||
| -rw-r--r-- | src/mailman/runners/tests/test_nntp.py | 18 | ||||
| -rw-r--r-- | src/mailman/styles/default.py | 6 | ||||
| -rw-r--r-- | src/mailman/utilities/importer.py | 4 |
12 files changed, 54 insertions, 49 deletions
diff --git a/src/mailman/database/schema/mm_20120407000000.py b/src/mailman/database/schema/mm_20120407000000.py index 84c563d45..bfeb1060b 100644 --- a/src/mailman/database/schema/mm_20120407000000.py +++ b/src/mailman/database/schema/mm_20120407000000.py @@ -48,10 +48,10 @@ def upgrade_sqlite(database, store, version, module_path): database.load_schema( store, version, 'sqlite_{0}_01.sql'.format(version), module_path) results = store.execute( - 'select id, news_prefix_subject_too, archive, archive_private ' - 'from mailinglist;') + 'select id, news_prefix_subject_too, news_moderation, ' + 'archive, archive_private from mailinglist;') for value in results: - id, news_prefix, archive, archive_private = value + id, news_prefix, news_moderation, archive, archive_private = value # Figure out what the new archive_policy column value should be. if archive == 0: archive_policy = int(ArchivePolicy.never) @@ -61,8 +61,10 @@ def upgrade_sqlite(database, store, version, module_path): archive_policy = int(ArchivePolicy.public) store.execute( 'update ml_backup set ' - ' nntp_prefix_subject_too = {0}, ' - ' archive_policy = {1} ' - 'where id = {2};'.format(news_prefix, archive_policy, id)) + ' nntp_moderation = {0}, ' + ' nntp_prefix_subject_too = {1}, ' + ' archive_policy = {2} ' + 'where id = {2};'.format(news_moderation, news_prefix, + archive_policy, id)) store.execute('drop table mailinglist;') store.execute('alter table ml_backup rename to mailinglist;') diff --git a/src/mailman/database/schema/sqlite_20120407000000_01.sql b/src/mailman/database/schema/sqlite_20120407000000_01.sql index 4fae9ed9d..58201fb9b 100644 --- a/src/mailman/database/schema/sqlite_20120407000000_01.sql +++ b/src/mailman/database/schema/sqlite_20120407000000_01.sql @@ -10,11 +10,13 @@ -- REM archive -- REM archive_private -- REM archive_volume_frequency +-- REM news_moderation -- REM news_prefix_subject_too -- REM nntp_host -- -- THESE COLUMNS ARE ADDED BY THE PYTHON MIGRATION LAYER: -- ADD archive_policy +-- ADD newsgroup_moderation -- ADD nntp_prefix_subject_too -- LP: #971013 @@ -95,7 +97,6 @@ CREATE TABLE ml_backup( mime_is_default_digest BOOLEAN, moderator_password TEXT, new_member_options INTEGER, - news_moderation INTEGER, nondigestable BOOLEAN, nonmember_rejection_notice TEXT, obscure_addresses BOOLEAN, @@ -206,7 +207,6 @@ INSERT INTO ml_backup SELECT mime_is_default_digest, moderator_password, new_member_options, - news_moderation, nondigestable, nonmember_rejection_notice, obscure_addresses, @@ -241,3 +241,4 @@ INSERT INTO ml_backup SELECT -- Add the new columns. They'll get inserted at the Python layer. ALTER TABLE ml_backup ADD COLUMN archive_policy INTEGER; ALTER TABLE ml_backup ADD COLUMN nntp_prefix_subject_too INTEGER; +ALTER TABLE ml_backup ADD COLUMN newsgroup_moderation INTEGER; diff --git a/src/mailman/database/tests/test_migrations.py b/src/mailman/database/tests/test_migrations.py index 9800a7bd7..5333083f2 100644 --- a/src/mailman/database/tests/test_migrations.py +++ b/src/mailman/database/tests/test_migrations.py @@ -48,6 +48,7 @@ class TestMigration20120407(unittest.TestCase): Circa: 3.0b1 -> 3.0b2 table mailinglist: + * news_moderation -> newsgroup_moderation * news_prefix_subject_too -> nntp_prefix_subject_too * ADD archive_policy * REMOVE archive @@ -90,6 +91,7 @@ class TestMigration20120407(unittest.TestCase): for present in ('archive', 'archive_private', 'archive_volume_frequency', + 'news_moderation', 'news_prefix_subject_too', 'nntp_host'): # This should not produce an exception. Is there some better test @@ -106,13 +108,6 @@ class TestMigration20120407(unittest.TestCase): database.initialize() # Load all the database SQL to just before ours. database.load_migrations('20120406999999') - # Populate the test database with a domain and a mailing list. - with temporary_db(database): - getUtility(IDomainManager).add( - 'example.com', 'An example domain.', - 'http://lists.example.com', 'postmaster@example.com') - mlist = create_list('test@example.com') - del mlist database.commit() # Load all migrations, up to and including this one. database.load_migrations('20120407000000') @@ -126,6 +121,7 @@ class TestMigration20120407(unittest.TestCase): for missing in ('archive', 'archive_private', 'archive_volume_frequency', + 'news_moderation', 'news_prefix_subject_too', 'nntp_host'): self.assertRaises(sqlite3.OperationalError, diff --git a/src/mailman/interfaces/mailinglist.py b/src/mailman/interfaces/mailinglist.py index bced070d3..485fa92bc 100644 --- a/src/mailman/interfaces/mailinglist.py +++ b/src/mailman/interfaces/mailinglist.py @@ -250,6 +250,13 @@ class IMailingList(Interface): # Delivery. + archive_policy = Attribute( + """The policy for archiving messages to this mailing list. + + The value is an `ArchivePolicy` enum. Use this to archive the mailing + list publicly, privately, or not at all. + """) + last_post_at = Attribute( """The date and time a message was last posted to the mailing list.""") @@ -511,6 +518,9 @@ class IMailingList(Interface): without any other checks. """) + newsgroup_moderation = Attribute( + """The moderation policy for the linked newsgroup, if there is one.""") + # Bounces. forward_unrecognized_bounces_to = Attribute( diff --git a/src/mailman/interfaces/nntp.py b/src/mailman/interfaces/nntp.py index d5d08d3f0..61063236c 100644 --- a/src/mailman/interfaces/nntp.py +++ b/src/mailman/interfaces/nntp.py @@ -17,7 +17,7 @@ __metaclass__ = type __all__ = [ - 'NewsModeration', + 'NewsgroupModeration', ] @@ -25,7 +25,7 @@ from flufl.enum import Enum -class NewsModeration(Enum): +class NewsgroupModeration(Enum): # The newsgroup is not moderated. none = 0 # The newsgroup is moderated, but allows for an open posting policy. diff --git a/src/mailman/model/mailinglist.py b/src/mailman/model/mailinglist.py index d51c89514..18c411fc4 100644 --- a/src/mailman/model/mailinglist.py +++ b/src/mailman/model/mailinglist.py @@ -40,6 +40,7 @@ from mailman.database.model import Model from mailman.database.types import Enum from mailman.interfaces.action import Action, FilterAction from mailman.interfaces.address import IAddress +from mailman.interfaces.archiver import ArchivePolicy from mailman.interfaces.autorespond import ResponseAction from mailman.interfaces.bounce import UnrecognizedBounceDisposition from mailman.interfaces.digests import DigestFrequency @@ -51,7 +52,7 @@ from mailman.interfaces.mailinglist import ( from mailman.interfaces.member import ( AlreadySubscribedError, MemberRole, MissingPreferredAddressError) from mailman.interfaces.mime import FilterType -from mailman.interfaces.nntp import NewsModeration +from mailman.interfaces.nntp import NewsgroupModeration from mailman.interfaces.user import IUser from mailman.model import roster from mailman.model.digests import OneLastDigest @@ -103,9 +104,7 @@ class MailingList(Model): admin_immed_notify = Bool() admin_notify_mchanges = Bool() administrivia = Bool() - archive = Bool() # XXX - archive_private = Bool() # XXX - archive_volume_frequency = Int() # XXX + archive_policy = Enum(ArchivePolicy) # Automatic responses. autoresponse_grace_period = TimeDelta() autorespond_owner = Enum(ResponseAction) @@ -162,9 +161,8 @@ class MailingList(Model): mime_is_default_digest = Bool() moderator_password = RawStr() new_member_options = Int() - news_moderation = Enum(NewsModeration) - news_prefix_subject_too = Bool() - nntp_host = Unicode() + newsgroup_moderation = Enum(NewsgroupModeration) + nntp_prefix_subject_too = Bool() nondigestable = Bool() nonmember_rejection_notice = Unicode() obscure_addresses = Bool() diff --git a/src/mailman/rules/docs/news-moderation.rst b/src/mailman/rules/docs/news-moderation.rst index c695740fa..651c21bb4 100644 --- a/src/mailman/rules/docs/news-moderation.rst +++ b/src/mailman/rules/docs/news-moderation.rst @@ -16,8 +16,8 @@ directly to the mailing list. Set the list configuration variable to enable newsgroup moderation. - >>> from mailman.interfaces.nntp import NewsModeration - >>> mlist.news_moderation = NewsModeration.moderated + >>> from mailman.interfaces.nntp import NewsgroupModeration + >>> mlist.newsgroup_moderation = NewsgroupModeration.moderated And now all messages will match the rule. @@ -32,6 +32,6 @@ And now all messages will match the rule. When moderation is turned off, the rule does not match. - >>> mlist.news_moderation = NewsModeration.none + >>> mlist.news_moderation = NewsgroupModeration.none >>> rule.check(mlist, msg, {}) False diff --git a/src/mailman/rules/news_moderation.py b/src/mailman/rules/news_moderation.py index 4ca9a0d8a..e43bca3b7 100644 --- a/src/mailman/rules/news_moderation.py +++ b/src/mailman/rules/news_moderation.py @@ -28,7 +28,7 @@ __all__ = [ from zope.interface import implements from mailman.core.i18n import _ -from mailman.interfaces.nntp import NewsModeration +from mailman.interfaces.nntp import NewsgroupModeration from mailman.interfaces.rules import IRule @@ -46,4 +46,4 @@ class ModeratedNewsgroup: def check(self, mlist, msg, msgdata): """See `IRule`.""" - return mlist.news_moderation == NewsModeration.moderated + return mlist.news_moderation == NewsgroupModeration.moderated diff --git a/src/mailman/runners/nntp.py b/src/mailman/runners/nntp.py index 8339c735e..4b6cd414f 100644 --- a/src/mailman/runners/nntp.py +++ b/src/mailman/runners/nntp.py @@ -35,7 +35,7 @@ from cStringIO import StringIO from mailman.config import config from mailman.core.runner import Runner -from mailman.interfaces.nntp import NewsModeration +from mailman.interfaces.nntp import NewsgroupModeration COMMA = ',' COMMASPACE = ', ' @@ -106,8 +106,8 @@ def prepare_message(mlist, msg, msgdata): # software to accept the posting, and not forward it on to the n.g.'s # moderation address. The posting would not have gotten here if it hadn't # already been approved. 1 == open list, mod n.g., 2 == moderated - if mlist.news_moderation in (NewsModeration.open_moderated, - NewsModeration.moderated): + if mlist.newsgroup_moderation in (NewsgroupModeration.open_moderated, + NewsgroupModeration.moderated): del msg['approved'] msg['Approved'] = mlist.posting_address # Should we restore the original, non-prefixed subject for gatewayed @@ -116,9 +116,7 @@ def prepare_message(mlist, msg, msgdata): # came from mailing list user. stripped_subject = msgdata.get('stripped_subject', msgdata.get('original_subject')) - # XXX 2012-03-31 BAW: rename news_prefix_subject_too to nntp_. This - # requires a schema change. - if not mlist.news_prefix_subject_too and stripped_subject is not None: + if not mlist.nntp_prefix_subject_too and stripped_subject is not None: del msg['subject'] msg['subject'] = stripped_subject # Add the appropriate Newsgroups header. Multiple Newsgroups headers are diff --git a/src/mailman/runners/tests/test_nntp.py b/src/mailman/runners/tests/test_nntp.py index 426e829d8..477bccfa3 100644 --- a/src/mailman/runners/tests/test_nntp.py +++ b/src/mailman/runners/tests/test_nntp.py @@ -33,7 +33,7 @@ import unittest from mailman.app.lifecycle import create_list from mailman.config import config -from mailman.interfaces.nntp import NewsModeration +from mailman.interfaces.nntp import NewsgroupModeration from mailman.runners import nntp from mailman.testing.helpers import ( LogFileMark, @@ -67,7 +67,7 @@ Testing # Approved header, which NNTP software uses to forward to the # newsgroup. The message would not have gotten to the mailing list if # it wasn't already approved. - self._mlist.news_moderation = NewsModeration.moderated + self._mlist.newsgroup_moderation = NewsgroupModeration.moderated nntp.prepare_message(self._mlist, self._msg, {}) self.assertEqual(self._msg['approved'], 'test@example.com') @@ -76,14 +76,14 @@ Testing # message will get an Approved header, which NNTP software uses to # forward to the newsgroup. The message would not have gotten to the # mailing list if it wasn't already approved. - self._mlist.news_moderation = NewsModeration.open_moderated + self._mlist.newsgroup_moderation = NewsgroupModeration.open_moderated nntp.prepare_message(self._mlist, self._msg, {}) self.assertEqual(self._msg['approved'], 'test@example.com') def test_moderation_removes_previous_approved_header(self): # Any existing Approved header is removed from moderated messages. self._msg['Approved'] = 'a bogus approval' - self._mlist.news_moderation = NewsModeration.moderated + self._mlist.newsgroup_moderation = NewsgroupModeration.moderated nntp.prepare_message(self._mlist, self._msg, {}) headers = self._msg.get_all('approved') self.assertEqual(len(headers), 1) @@ -92,7 +92,7 @@ Testing def test_open_moderation_removes_previous_approved_header(self): # Any existing Approved header is removed from moderated messages. self._msg['Approved'] = 'a bogus approval' - self._mlist.news_moderation = NewsModeration.open_moderated + self._mlist.newsgroup_moderation = NewsgroupModeration.open_moderated nntp.prepare_message(self._mlist, self._msg, {}) headers = self._msg.get_all('approved') self.assertEqual(len(headers), 1) @@ -102,7 +102,7 @@ Testing # The cook-headers handler adds the original and/or stripped (of the # prefix) subject to the metadata. Assume that handler's been run; # check the Subject header. - self._mlist.news_prefix_subject_too = False + self._mlist.nntp_prefix_subject_too = False del self._msg['subject'] self._msg['subject'] = 'Re: Your test' msgdata = dict(stripped_subject='Your test') @@ -115,7 +115,7 @@ Testing # The cook-headers handler adds the original and/or stripped (of the # prefix) subject to the metadata. Assume that handler's been run; # check the Subject header. - self._mlist.news_prefix_subject_too = False + self._mlist.nntp_prefix_subject_too = False del self._msg['subject'] self._msg['subject'] = 'Re: Your test' msgdata = dict(original_subject='Your test') @@ -128,7 +128,7 @@ Testing # The cook-headers handler adds the original and/or stripped (of the # prefix) subject to the metadata. Assume that handler's been run; # check the Subject header. - self._mlist.news_prefix_subject_too = True + self._mlist.nntp_prefix_subject_too = True del self._msg['subject'] self._msg['subject'] = 'Re: Your test' msgdata = dict(stripped_subject='Your test') @@ -141,7 +141,7 @@ Testing # The cook-headers handler adds the original and/or stripped (of the # prefix) subject to the metadata. Assume that handler's been run; # check the Subject header. - self._mlist.news_prefix_subject_too = True + self._mlist.nntp_prefix_subject_too = True del self._msg['subject'] self._msg['subject'] = 'Re: Your test' msgdata = dict(original_subject='Your test') diff --git a/src/mailman/styles/default.py b/src/mailman/styles/default.py index b6900dca6..82deff026 100644 --- a/src/mailman/styles/default.py +++ b/src/mailman/styles/default.py @@ -36,7 +36,7 @@ from mailman.interfaces.bounce import UnrecognizedBounceDisposition from mailman.interfaces.digests import DigestFrequency from mailman.interfaces.autorespond import ResponseAction from mailman.interfaces.mailinglist import Personalization, ReplyToMunging -from mailman.interfaces.nntp import NewsModeration +from mailman.interfaces.nntp import NewsgroupModeration from mailman.interfaces.styles import IStyle @@ -175,10 +175,10 @@ from: .*@uplinkpro.com mlist.linked_newsgroup = '' mlist.gateway_to_news = False mlist.gateway_to_mail = False - mlist.news_prefix_subject_too = True + mlist.nntp_prefix_subject_too = True # In patch #401270, this was called newsgroup_is_moderated, but the # semantics weren't quite the same. - mlist.news_moderation = NewsModeration.none + mlist.newsgroup_moderation = NewsgroupModeration.none # Topics # # `topics' is a list of 4-tuples of the following form: diff --git a/src/mailman/utilities/importer.py b/src/mailman/utilities/importer.py index f77d86e9a..7c562e331 100644 --- a/src/mailman/utilities/importer.py +++ b/src/mailman/utilities/importer.py @@ -31,7 +31,7 @@ import datetime from mailman.interfaces.autorespond import ResponseAction from mailman.interfaces.digests import DigestFrequency from mailman.interfaces.mailinglist import Personalization, ReplyToMunging -from mailman.interfaces.nntp import NewsModeration +from mailman.interfaces.nntp import NewsgroupModeration @@ -47,7 +47,7 @@ TYPES = dict( bounce_info_stale_after=seconds_to_delta, bounce_you_are_disabled_warnings_interval=seconds_to_delta, digest_volume_frequency=DigestFrequency, - news_moderation=NewsModeration, + newsgroup_moderation=NewsgroupModeration, personalize=Personalization, reply_goes_to_list=ReplyToMunging, ) |
