diff options
Diffstat (limited to 'src/mailman/interfaces')
| -rw-r--r-- | src/mailman/interfaces/address.py | 2 | ||||
| -rw-r--r-- | src/mailman/interfaces/domain.py | 87 | ||||
| -rw-r--r-- | src/mailman/interfaces/listmanager.py | 32 | ||||
| -rw-r--r-- | src/mailman/interfaces/mailinglist.py | 32 | ||||
| -rw-r--r-- | src/mailman/interfaces/member.py | 7 | ||||
| -rw-r--r-- | src/mailman/interfaces/membership.py | 22 | ||||
| -rw-r--r-- | src/mailman/interfaces/rest.py | 46 | ||||
| -rw-r--r-- | src/mailman/interfaces/system.py | 16 |
8 files changed, 35 insertions, 209 deletions
diff --git a/src/mailman/interfaces/address.py b/src/mailman/interfaces/address.py index 2b074ddab..d54ea64c3 100644 --- a/src/mailman/interfaces/address.py +++ b/src/mailman/interfaces/address.py @@ -30,7 +30,6 @@ __all__ = [ ] -from lazr.restful.declarations import error_status from zope.interface import Interface, Attribute from mailman.interfaces.errors import MailmanError @@ -53,7 +52,6 @@ class AddressNotLinkedError(AddressError): """The address is not linked to the user.""" -@error_status(400) class InvalidEmailAddressError(AddressError): """Email address is invalid.""" diff --git a/src/mailman/interfaces/domain.py b/src/mailman/interfaces/domain.py index 340cddd79..b7fc1c91f 100644 --- a/src/mailman/interfaces/domain.py +++ b/src/mailman/interfaces/domain.py @@ -23,62 +23,44 @@ __metaclass__ = type __all__ = [ 'BadDomainSpecificationError', 'IDomain', - 'IDomainCollection', 'IDomainManager', ] -from lazr.restful.declarations import ( - collection_default_content, error_status, export_as_webservice_collection, - export_as_webservice_entry, export_factory_operation, exported) from zope.interface import Interface, Attribute -from zope.schema import TextLine from mailman.core.errors import MailmanError from mailman.core.i18n import _ -@error_status(400) class BadDomainSpecificationError(MailmanError): """The specification of a virtual domain is invalid or duplicated.""" + def __init__(self, domain): + super(BadDomainSpecificationError, self).__init__(domain) + self.domain = domain + class IDomain(Interface): """Interface representing domains.""" - export_as_webservice_entry() - - email_host = exported(TextLine( - title=_('Email host name'), - description=_('The host name for email for this domain.'), - )) + email_host = Attribute('The host name for email for this domain.') - url_host = exported(TextLine( - title=_('Web host name'), - description=_('The host name for the web interface for this domain.') - )) + url_host = Attribute( + 'The host name for the web interface for this domain.') - base_url = exported(TextLine( - title=_('Base URL'), - description=_("""\ - The base url for the Mailman server at this domain, which includes the - scheme and host name."""), - )) + base_url = Attribute("""\ + The base url for the Mailman server at this domain, which includes the + scheme and host name.""") - description = exported(TextLine( - title=_('Description'), - description=_('The human readable description of the domain name.'), - )) + description = Attribute( + 'The human readable description of the domain name.') - contact_address = exported(TextLine( - title=_('Contact address'), - description=_("""\ - The contact address for the human at this domain. - - E.g. postmaster@example.com"""), - )) + contact_address = Attribute("""\ + The contact address for the human at this domain. + E.g. postmaster@example.com""") def confirm_url(token=''): """The url used for various forms of confirmation. @@ -158,42 +140,3 @@ class IDomainManager(Interface): :return: True if this domain is known. :rtype: bool """ - - - -class IDomainCollection(Interface): - """The set of domains available via the REST API.""" - - export_as_webservice_collection(IDomain) - - @collection_default_content() - def get_domains(): - """The list of all domains. - - :return: The list of all known domains. - :rtype: list of `IDomain` - """ - - @export_factory_operation( - IDomain, - ('email_host', 'description', 'base_url', 'contact_address')) - def new(email_host, description=None, base_url=None, contact_address=None): - """Add a new domain. - - :param email_host: The email host name for the domain. - :type email_host: string - :param description: The description of the domain. - :type description: string - :param base_url: The base url, including the scheme for the web - interface of the domain. If not given, it defaults to - http://`email_host`/ - :type base_url: string - :param contact_address: The email contact address for the human - managing the domain. If not given, defaults to - postmaster@`email_host` - :type contact_address: string - :return: The new domain object - :rtype: `IDomain` - :raises `BadDomainSpecificationError`: when the `email_host` is - already registered. - """ diff --git a/src/mailman/interfaces/listmanager.py b/src/mailman/interfaces/listmanager.py index 5958d677a..f24230852 100644 --- a/src/mailman/interfaces/listmanager.py +++ b/src/mailman/interfaces/listmanager.py @@ -27,9 +27,6 @@ __all__ = [ ] -from lazr.restful.declarations import ( - collection_default_content, error_status, export_as_webservice_collection, - export_factory_operation) from zope.interface import Interface, Attribute from mailman.interfaces.errors import MailmanError @@ -37,7 +34,6 @@ from mailman.interfaces.mailinglist import IMailingList -@error_status(400) class ListAlreadyExistsError(MailmanError): """Attempted to create a mailing list that already exists. @@ -46,7 +42,6 @@ class ListAlreadyExistsError(MailmanError): """ -@error_status(400) class NoSuchListError(MailmanError): """Attempt to access a mailing list that does not exist.""" @@ -68,8 +63,6 @@ class IListManager(Interface): `mylist@example.com`. """ - export_as_webservice_collection(IMailingList) - def create(fqdn_listname): """Create a mailing list with the given name. @@ -100,32 +93,19 @@ class IListManager(Interface): """An iterator over all the mailing list objects managed by this list manager.""") + def __iter__(): + """An iterator over all the mailing lists. + + :return: iterator over `IMailingList`. + """ + names = Attribute( """An iterator over the fully qualified list names of all mailing lists managed by this list manager.""") - @collection_default_content() def get_mailing_lists(): """The list of all mailing lists. :return: The list of all known mailing lists. :rtype: list of `IMailingList` """ - - @export_factory_operation(IMailingList, ('fqdn_listname',)) - def new(fqdn_listname): - """Add a new maling list. - - The mailing may not exist yet, but the domain specified in - `fqdn_listname` must exist. - - :param fqdn_listname: The fully qualified name for the new - mailing list. - :type fqdn_listname: string - :return: The new mailing list - :rtype: `IMailingList` - :raises `BadDomainSpecificationError`: when the hostname part of - `fqdn_listname` does not exist. - :raises `ListAlreadyExistsError`: when the mailing list already - exists. - """ diff --git a/src/mailman/interfaces/mailinglist.py b/src/mailman/interfaces/mailinglist.py index 0efe00625..2e2083e72 100644 --- a/src/mailman/interfaces/mailinglist.py +++ b/src/mailman/interfaces/mailinglist.py @@ -30,11 +30,8 @@ __all__ = [ ] -from lazr.restful.declarations import ( - export_as_webservice_entry, exported) from munepy import Enum from zope.interface import Interface, Attribute -from zope.schema import TextLine from mailman.core.i18n import _ @@ -71,53 +68,40 @@ class DigestFrequency(Enum): class IMailingList(Interface): """A mailing list.""" - # Use a different singular and plural name for the resource type than - # lazr.restful gives it as a default (which is normally taken from the - # interface name). - export_as_webservice_entry('list', 'lists') - # List identity - list_name = exported(TextLine( - title=_('Short name'), - description=_("""\ + list_name = Attribute("""\ The read-only short name of the mailing list. Note that where a Mailman installation supports multiple domains, this short name may not be unique. Use the fqdn_listname attribute for a guaranteed unique id for the mailing list. This short name is always the local part of the posting email address. For example, if messages are posted to mylist@example.com, then the list_name is 'mylist'. - """))) - host_name = exported(TextLine( - title=_('Host name'), - description=_("""\ + """) + host_name = Attribute("""\ The read-only domain name 'hosting' this mailing list. This is always the domain name part of the posting email address, and it may bear no relationship to the web url used to access this mailing list. For example, if messages are posted to mylist@example.com, then the host_name is 'example.com'. - """))) + """) - fqdn_listname = exported(TextLine( - title=_('Fully qualified list name'), - description=_("""\ + fqdn_listname = Attribute("""\ The read-only fully qualified name of the mailing list. This is the guaranteed unique id for the mailing list, and it is always the address to which messages are posted, e.g. mylist@example.com. It is always comprised of the list_name + '@' + host_name. - """))) + """) domain = Attribute( """The `IDomain` that this mailing list is defined in.""") - real_name = exported(TextLine( - title=_('Real name'), - description=_("""\ + real_name = Attribute("""\ The short human-readable descriptive name for the mailing list. By default, this is the capitalized `list_name`, but it can be changed to anything. This is used in locations such as the message footers and Subject prefix. - """))) + """) list_id = Attribute( """The RFC 2919 List-ID header value.""") diff --git a/src/mailman/interfaces/member.py b/src/mailman/interfaces/member.py index 871957922..df5ccc935 100644 --- a/src/mailman/interfaces/member.py +++ b/src/mailman/interfaces/member.py @@ -32,8 +32,6 @@ __all__ = [ ] -from lazr.restful.declarations import ( - error_status, export_as_webservice_entry, exported) from munepy import Enum from zope.interface import Interface, Attribute @@ -78,7 +76,6 @@ class MembershipError(MailmanError): """Base exception for all membership errors.""" -@error_status(400) class AlreadySubscribedError(MembershipError): """The member is already subscribed to the mailing list with this role.""" @@ -93,7 +90,6 @@ class AlreadySubscribedError(MembershipError): self._address, self._role, self._fqdn_listname) -@error_status(400) class MembershipIsBannedError(MembershipError): """The address is not allowed to subscribe to the mailing list.""" @@ -107,7 +103,6 @@ class MembershipIsBannedError(MembershipError): self._address, self._mlist) -@error_status(400) class NotAMemberError(MembershipError): """The address is not a member of the mailing list.""" @@ -125,8 +120,6 @@ class NotAMemberError(MembershipError): class IMember(Interface): """A member of a mailing list.""" - export_as_webservice_entry() - mailing_list = Attribute( """The mailing list subscribed to.""") diff --git a/src/mailman/interfaces/membership.py b/src/mailman/interfaces/membership.py index 6e6176e8f..f42516ad1 100644 --- a/src/mailman/interfaces/membership.py +++ b/src/mailman/interfaces/membership.py @@ -25,11 +25,7 @@ __all__ = [ ] -from lazr.restful.declarations import ( - collection_default_content, export_as_webservice_collection, - export_write_operation, operation_parameters) from zope.interface import Interface -from zope.schema import TextLine from mailman.core.i18n import _ from mailman.interfaces.member import IMember @@ -39,9 +35,6 @@ from mailman.interfaces.member import IMember class ISubscriptionService(Interface): """Subscription services for the REST API.""" - export_as_webservice_collection(IMember) - - @collection_default_content() def get_members(): """Return a sequence of all members of all mailing lists. @@ -55,13 +48,9 @@ class ISubscriptionService(Interface): :rtype: list of `IMember` """ - @operation_parameters( - fqdn_listname=TextLine(), - address=TextLine(), - real_name=TextLine(), - delivery_mode=TextLine(), - ) - @export_write_operation() + def __iter__(): + """See `get_members()`.""" + def join(fqdn_listname, address, real_name=None, delivery_mode=None): """Subscribe to a mailing list. @@ -94,11 +83,6 @@ class ISubscriptionService(Interface): :raises ValueError: when `delivery_mode` is invalid. """ - @operation_parameters( - fqdn_listname=TextLine(), - address=TextLine(), - ) - @export_write_operation() def leave(fqdn_listname, address): """Unsubscribe from a mailing list. diff --git a/src/mailman/interfaces/rest.py b/src/mailman/interfaces/rest.py deleted file mode 100644 index f5eb59bc9..000000000 --- a/src/mailman/interfaces/rest.py +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (C) 2009-2010 by the Free Software Foundation, Inc. -# -# This file is part of GNU Mailman. -# -# GNU Mailman 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 3 of the License, or (at your option) -# any later version. -# -# GNU Mailman 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 -# GNU Mailman. If not, see <http://www.gnu.org/licenses/>. - -"""Interfaces for the RESTful admin server.""" - -from __future__ import absolute_import, unicode_literals - -__metaclass__ = type -__all__ = [ - 'APIValueError', - 'IResolvePathNames', - ] - - -from lazr.restful.declarations import error_status -from zope.interface import Interface - -from mailman.core.errors import MailmanError - - - -@error_status(400) -class APIValueError(MailmanError, ValueError): - """A `ValueError` from the REST API.""" - - - -class IResolvePathNames(Interface): - """A marker interface objects that implement simple traversal.""" - - def get(name): - """Traverse to a contained object.""" diff --git a/src/mailman/interfaces/system.py b/src/mailman/interfaces/system.py index 9f2e275fa..39156315f 100644 --- a/src/mailman/interfaces/system.py +++ b/src/mailman/interfaces/system.py @@ -25,9 +25,7 @@ __all__ = [ ] -from lazr.restful.declarations import export_as_webservice_entry, exported -from zope.interface import Interface -from zope.schema import TextLine +from zope.interface import Interface, Attribute from mailman.core.i18n import _ @@ -36,14 +34,6 @@ from mailman.core.i18n import _ class ISystem(Interface): """Information about the Mailman system.""" - export_as_webservice_entry() + mailman_version = Attribute('The GNU Mailman version.') - mailman_version = exported(TextLine( - title=_('Mailman version'), - description=_('The GNU Mailman version.'), - )) - - python_version = exported(TextLine( - title=_('Python version'), - description=_('The Python version.'), - )) + python_version = Attribute('The Python version.') |
