summaryrefslogtreecommitdiff
path: root/src/mailman/interfaces
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/interfaces')
-rw-r--r--src/mailman/interfaces/address.py11
-rw-r--r--src/mailman/interfaces/mailinglist.py18
-rw-r--r--src/mailman/interfaces/user.py18
3 files changed, 36 insertions, 11 deletions
diff --git a/src/mailman/interfaces/address.py b/src/mailman/interfaces/address.py
index c051c9b0c..2f6d05bba 100644
--- a/src/mailman/interfaces/address.py
+++ b/src/mailman/interfaces/address.py
@@ -41,6 +41,7 @@ class AddressError(MailmanError):
"""A general address-related error occurred."""
def __init__(self, address):
+ super(AddressError, self).__init__()
self.address = address
def __str__(self):
@@ -99,16 +100,6 @@ class IAddress(Interface):
None if the email address has not yet been validated. The specific
method of validation is not defined here.""")
- def subscribe(mailing_list, role):
- """Subscribe the address to the given mailing list with the given role.
-
- :param mailing_list: The IMailingList being subscribed to.
- :param role: A MemberRole enum value.
- :return: The IMember representing this subscription.
- :raises AlreadySubscribedError: If the address is already subscribed
- to the mailing list with the given role.
- """
-
preferences = Attribute(
"""This address's preferences.""")
diff --git a/src/mailman/interfaces/mailinglist.py b/src/mailman/interfaces/mailinglist.py
index d8c0ebb26..23d21cd34 100644
--- a/src/mailman/interfaces/mailinglist.py
+++ b/src/mailman/interfaces/mailinglist.py
@@ -182,7 +182,7 @@ class IMailingList(Interface):
def confirm_address(cookie=''):
"""The address used for various forms of email confirmation."""
- # Rosters.
+ # Rosters and subscriptions.
owners = Attribute(
"""The IUser owners of this mailing list.
@@ -232,6 +232,22 @@ class IMailingList(Interface):
:rtype: Roster
"""
+ def subscribe(subscriber, role):
+ """Subscribe the given address or user to the mailing list.
+
+ :param subscriber: The address or user to subscribe to the mailing
+ list. The user's preferred address receives deliveries, if she
+ has one, otherwise no address for the user appears in the rosters.
+ :type subscriber: `IUser` or `IAddress`
+ :param role: The role being subscribed to (e.g. a member, owner, or
+ moderator of a mailing list.
+ :type role: `MemberRole`
+ :return: The member object representing the subscription.
+ :rtype: `IMember`
+ :raises AlreadySubscribedError: If the address or user is already
+ subscribed to the mailing list with the given role.
+ """
+
# Posting history.
last_post_at = Attribute(
diff --git a/src/mailman/interfaces/user.py b/src/mailman/interfaces/user.py
index 2c2652413..ceffec57f 100644
--- a/src/mailman/interfaces/user.py
+++ b/src/mailman/interfaces/user.py
@@ -22,11 +22,26 @@ from __future__ import absolute_import, unicode_literals
__metaclass__ = type
__all__ = [
'IUser',
+ 'UnverifiedAddressError',
]
from zope.interface import Interface, Attribute
+from mailman.interfaces.errors import MailmanError
+
+
+
+class UnverifiedAddressError(MailmanError):
+ """Unverified address cannot be used as a user's preferred address."""
+
+ def __init__(self, address):
+ super(UnverifiedAddressError, self).__init__()
+ self.address = address
+
+ def __str__(self):
+ return self.address
+
class IUser(Interface):
@@ -47,6 +62,9 @@ class IUser(Interface):
addresses = Attribute(
"""An iterator over all the `IAddresses` controlled by this user.""")
+ preferred_address = Attribute(
+ """The user's preferred `IAddress`. This must be validated.""")
+
memberships = Attribute(
"""A roster of this user's memberships.""")