diff options
Diffstat (limited to 'src/mailman/model')
| -rw-r--r-- | src/mailman/model/mailinglist.py | 12 | ||||
| -rw-r--r-- | src/mailman/model/tests/test_mailinglist.py | 15 |
2 files changed, 13 insertions, 14 deletions
diff --git a/src/mailman/model/mailinglist.py b/src/mailman/model/mailinglist.py index b5c83ff29..7761f2842 100644 --- a/src/mailman/model/mailinglist.py +++ b/src/mailman/model/mailinglist.py @@ -643,7 +643,7 @@ class HeaderMatch(Model): _position = Column('position', Integer, index=True, default=0) header = Column(Unicode) pattern = Column(Unicode) - action = Column(Enum(Action), nullable=True) + chain = Column(Unicode, nullable=True) def __init__(self, **kw): if 'position' in kw: @@ -711,7 +711,7 @@ class HeaderMatchList: del self._mailing_list.header_matches[:] @dbconnection - def append(self, store, header, pattern, action=None): + def append(self, store, header, pattern, chain=None): header = header.lower() existing = store.query(HeaderMatch).filter( HeaderMatch.mailing_list == self._mailing_list, @@ -726,20 +726,20 @@ class HeaderMatchList: last_position = -1 header_match = HeaderMatch( mailing_list=self._mailing_list, - header=header, pattern=pattern, action=action, + header=header, pattern=pattern, chain=chain, position=last_position + 1) store.add(header_match) store.expire(self._mailing_list, ['header_matches']) @dbconnection - def insert(self, store, index, header, pattern, action=None): - self.append(header, pattern, action) + def insert(self, store, index, header, pattern, chain=None): + self.append(header, pattern, chain) # Get the header match that was just added. header_match = store.query(HeaderMatch).filter( HeaderMatch.mailing_list == self._mailing_list, HeaderMatch.header == header.lower(), HeaderMatch.pattern == pattern, - HeaderMatch.action == action).one() + HeaderMatch.chain == chain).one() header_match.position = index store.expire(self._mailing_list, ['header_matches']) diff --git a/src/mailman/model/tests/test_mailinglist.py b/src/mailman/model/tests/test_mailinglist.py index 63e1cd300..1fc7b2e0d 100644 --- a/src/mailman/model/tests/test_mailinglist.py +++ b/src/mailman/model/tests/test_mailinglist.py @@ -30,7 +30,6 @@ import unittest from mailman.app.lifecycle import create_list from mailman.config import config from mailman.database.transaction import transaction -from mailman.interfaces.action import Action from mailman.interfaces.listmanager import IListManager from mailman.interfaces.mailinglist import ( IAcceptableAliasSet, IHeaderMatchList, IListArchiverSet) @@ -206,11 +205,11 @@ class TestHeaderMatch(unittest.TestCase): self.assertEqual(len(self._mlist.header_matches), 1) self.assertEqual(self._mlist.header_matches[0].header, 'header') - def test_action_defaults_to_none(self): + def test_chain_defaults_to_none(self): header_matches = IHeaderMatchList(self._mlist) header_matches.append('header', 'pattern') self.assertEqual(len(self._mlist.header_matches), 1) - self.assertEqual(self._mlist.header_matches[0].action, None) + self.assertEqual(self._mlist.header_matches[0].chain, None) def test_duplicate(self): header_matches = IHeaderMatchList(self._mlist) @@ -241,16 +240,16 @@ class TestHeaderMatch(unittest.TestCase): header_matches = IHeaderMatchList(self._mlist) header_matches.append('Header', 'pattern') header_matches.append('Subject', 'patt.*') - header_matches.append('From', '.*@example.com', Action.discard) - header_matches.append('From', '.*@example.org', Action.accept) - matches = [(match.header, match.pattern, match.action) + header_matches.append('From', '.*@example.com', 'discard') + header_matches.append('From', '.*@example.org', 'accept') + matches = [(match.header, match.pattern, match.chain) for match in IHeaderMatchList(self._mlist)] self.assertEqual( matches, [ ('header', 'pattern', None), ('subject', 'patt.*', None), - ('from', '.*@example.com', Action.discard), - ('from', '.*@example.org', Action.accept), + ('from', '.*@example.com', 'discard'), + ('from', '.*@example.org', 'accept'), ]) def test_clear(self): |
