diff options
Diffstat (limited to 'mailman/interfaces/listmanager.py')
| -rw-r--r-- | mailman/interfaces/listmanager.py | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/mailman/interfaces/listmanager.py b/mailman/interfaces/listmanager.py new file mode 100644 index 000000000..02b63af80 --- /dev/null +++ b/mailman/interfaces/listmanager.py @@ -0,0 +1,82 @@ +# Copyright (C) 2007-2008 by the Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. + +"""Interface for list storage, deleting, and finding.""" + +__metaclass__ = type +__all__ = [ + 'IListManager', + 'ListAlreadyExistsError', + ] + + +from zope.interface import Interface, Attribute +from mailman.interfaces.errors import MailmanError + + + +class ListAlreadyExistsError(MailmanError): + """Attempted to create a mailing list that already exists. + + Mailing list objects must be uniquely named by their fully qualified list + name. + """ + + + +class IListManager(Interface): + """The interface of the global list manager. + + The list manager manages `IMailingList` objects. You can add and remove + `IMailingList` objects from the list manager, and you can retrieve them + from the manager via their fully qualified list name, e.g.: + `mylist@example.com`. + """ + + def create(fqdn_listname): + """Create a mailing list with the given name. + + :type fqdn_listname: Unicode + :param fqdn_listname: The fully qualified name of the mailing list, + e.g. `mylist@example.com`. + :return: The newly created `IMailingList`. + :raise `ListAlreadyExistsError` if the named list already exists. + """ + + def get(fqdn_listname): + """Return the mailing list with the given name, if it exists. + + :type fqdn_listname: Unicode. + :param fqdn_listname: The fully qualified name of the mailing list. + :return: the matching `IMailingList` or None if the named list does + not exist. + """ + + def delete(mlist): + """Remove the mailing list from the database. + + :type mlist: `IMailingList` + :param mlist: The mailing list to delete. + """ + + mailing_lists = Attribute( + """An iterator over all the mailing list objects managed by this list + manager.""") + + names = Attribute( + """An iterator over the fully qualified list names of all mailing + lists managed by this list manager.""") |
