summaryrefslogtreecommitdiff
path: root/src/mailman/interfaces
diff options
context:
space:
mode:
authorAurélien Bompard2016-02-02 11:49:00 +0100
committerBarry Warsaw2016-02-29 21:52:13 -0500
commit15238cb5683eb9a0eab9dcd251f509a693a22451 (patch)
treeb57d661d1a6f2b1ff4b8c6920d898c36aa016164 /src/mailman/interfaces
parent14dbe7fb4a6b29ce955fa1c8d4c1859c514e8e13 (diff)
downloadmailman-15238cb5683eb9a0eab9dcd251f509a693a22451.tar.gz
mailman-15238cb5683eb9a0eab9dcd251f509a693a22451.tar.zst
mailman-15238cb5683eb9a0eab9dcd251f509a693a22451.zip
The order of a mailing list's header matches is significant
Add a numerical index property to HeaderMatch objects, and change the HeaderMatchSet manager to take the order into account. Items can now be inserted and removed by index.
Diffstat (limited to 'src/mailman/interfaces')
-rw-r--r--src/mailman/interfaces/mailinglist.py59
1 files changed, 52 insertions, 7 deletions
diff --git a/src/mailman/interfaces/mailinglist.py b/src/mailman/interfaces/mailinglist.py
index 25690945e..533bf89a7 100644
--- a/src/mailman/interfaces/mailinglist.py
+++ b/src/mailman/interfaces/mailinglist.py
@@ -21,6 +21,7 @@ __all__ = [
'IAcceptableAlias',
'IAcceptableAliasSet',
'IHeaderMatch',
+ 'IHeaderMatchList',
'IListArchiver',
'IListArchiverSet',
'IMailingList',
@@ -873,14 +874,14 @@ class IHeaderMatch(Interface):
""")
-class IHeaderMatchSet(Interface):
- """The set of header matching rules for a mailing list."""
+class IHeaderMatchList(Interface):
+ """The list of header matching rules for a mailing list."""
def clear():
- """Clear the set of header matching rules."""
+ """Clear the list of header matching rules."""
- def add(header, pattern, chain=None):
- """Add the given header matching rule to this mailing list's set.
+ def append(header, pattern, chain=None):
+ """Append the given rule to this mailing list's header match list.
:param header: The email header to filter on. It will be converted to
lower case for consistency.
@@ -894,8 +895,26 @@ class IHeaderMatchSet(Interface):
mailing list.
"""
+ def insert(index, header, pattern, chain=None):
+ """Insert the given rule at the given index position in this mailing
+ list's header match list.
+
+ :param index: The index to insert the rule at.
+ :type index: integer
+ :param header: The email header to filter on. It will be converted to
+ lower case for consistency.
+ :type header: string
+ :param pattern: The regular expression to use.
+ :type pattern: string
+ :param chain: The chain to jump to, or None to use the site-wide
+ configuration. Defaults to None.
+ :type chain: string or None
+ :raises ValueError: if the header/pattern pair already exists for this
+ mailing list.
+ """
+
def remove(header, pattern):
- """Remove the given header matching rule from this mailing list's set.
+ """Remove the given rule from this mailing list's header match list.
:param header: The email header part of the rule to be removed.
:type header: string
@@ -903,8 +922,34 @@ class IHeaderMatchSet(Interface):
:type pattern: string
"""
+ def __getitem__(key):
+ """Return the header match at the given index for this mailing list.
+
+ :param key: The index of the header match to return.
+ :type key: integer
+ :raises IndexError: if there is no header match at this index for
+ this mailing list.
+ :rtype: `IHeaderMatch`.
+ """
+
+ def __delitem__(key):
+ """Remove the rule at the given index from this mailing list's header
+ match list.
+
+ :param key: The index of the header match to remove.
+ :type key: integer
+ :raises IndexError: if there is no header match at this index for
+ this mailing list.
+ """
+
+ def __len__():
+ """Return the number of header matches for this mailing list.
+
+ :rtype: integer
+ """
+
def __iter__():
- """An iterator over all the IHeaderMatches defined in this set.
+ """An iterator over all the IHeaderMatches defined in this list.
:return: iterator over `IHeaderMatch`.
"""