summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Warsaw2010-02-25 20:40:44 -0500
committerBarry Warsaw2010-02-25 20:40:44 -0500
commit70dd8a96cc0e01b42737b46e30cf37b5c8fa0747 (patch)
tree4fee0c35625c78a38962aeea313ec7f76462199b
parentb2ae2b7795719f17cb2b6c7ed14e5b4c7c8eae47 (diff)
downloadmailman-70dd8a96cc0e01b42737b46e30cf37b5c8fa0747.tar.gz
mailman-70dd8a96cc0e01b42737b46e30cf37b5c8fa0747.tar.zst
mailman-70dd8a96cc0e01b42737b46e30cf37b5c8fa0747.zip
-rw-r--r--src/mailman/rest/configuration.py87
-rw-r--r--src/mailman/rest/urls.py142
-rw-r--r--src/mailman/rest/webservice.py54
3 files changed, 0 insertions, 283 deletions
diff --git a/src/mailman/rest/configuration.py b/src/mailman/rest/configuration.py
deleted file mode 100644
index 30e2607cb..000000000
--- a/src/mailman/rest/configuration.py
+++ /dev/null
@@ -1,87 +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/>.
-
-"""Mailman admin web service configuration."""
-
-from __future__ import absolute_import, unicode_literals
-
-__metaclass__ = type
-__all__ = [
- 'AdminWebServiceConfiguration',
- ]
-
-
-from lazr.config import as_boolean
-from lazr.restful.interfaces import IWebServiceConfiguration
-from lazr.restful.wsgi import BaseWSGIWebServiceConfiguration
-from zope.interface import implements
-
-from mailman import version
-from mailman.config import config
-
-
-
-# pylint: disable-msg=W0232,R0201
-class AdminWebServiceConfiguration(BaseWSGIWebServiceConfiguration):
- """A configuration object for the Mailman admin web service."""
-
- implements(IWebServiceConfiguration)
-
- @property
- def view_permission(self):
- """See `IWebServiceConfiguration`."""
- if config.webservice.view_permission.lower() == 'none':
- return None
- return config.webservice.view_permission
-
- path_override = None
-
- @property
- def use_https(self):
- """See `IWebServiceConfiguration`."""
- return as_boolean(config.webservice.use_https)
-
- # We currently have only one active version; the first entry in this list
- # should match the major.minor Mailman version. The second entry is just
- # an alias for the 'floating' development version.
- active_versions = [
- '{0.MAJOR_REV}.{0.MINOR_REV}'.format(version),
- 'dev',
- ]
- code_revision = version.VERSION
-
- @property
- def show_tracebacks(self):
- """See `IWebServiceConfiguration`."""
- return config.webservice.show_tracebacks
-
- default_batch_size = 50
- max_batch_size = 300
-
- def get_request_user(self):
- """See `IWebServiceConfiguration`."""
- return None
-
- @property
- def hostname(self):
- """See `IWebServiceConfiguration`."""
- return config.webservice.hostname
-
- @property
- def port(self):
- """See `IWebServiceConfiguration`."""
- return int(config.webservice.port)
diff --git a/src/mailman/rest/urls.py b/src/mailman/rest/urls.py
deleted file mode 100644
index 566696f82..000000000
--- a/src/mailman/rest/urls.py
+++ /dev/null
@@ -1,142 +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/>.
-
-"""Mappers from objects to absolute URLs."""
-
-from __future__ import absolute_import, unicode_literals
-
-__metaclass__ = type
-__all__ = [
- 'DomainURLMapper',
- 'FallbackURLMapper',
- 'MailingListURLMapper',
- 'MemberURLMapper',
- ]
-
-
-import logging
-
-from zope.component import getUtility
-from zope.interface import implements
-from zope.traversing.browser.interfaces import IAbsoluteURL
-
-from mailman.config import config
-from mailman.core.system import system
-from mailman.interfaces.listmanager import IListManager
-from mailman.interfaces.membership import ISubscriptionService
-from mailman.rest.configuration import AdminWebServiceConfiguration
-from mailman.rest.webservice import AdminWebServiceApplication
-
-log = logging.getLogger('mailman.http')
-
-
-
-class BasicURLMapper:
- """Base absolute URL mapper."""
-
- implements(IAbsoluteURL)
-
- def __init__(self, context, request):
- """Initialize with respect to a context and request."""
- self.context = context
- self.request = request
- self.webservice_config = AdminWebServiceConfiguration()
- # XXX 2010-02-16 barry This kind of sucks, but I don't understand how
- # to reconcile the way we used to do things with the way lazr.restful
- # as of 0.9.18 wants to do multiversion webservices. And really, I
- # don't care because right now I don't have any need for
- # multiversioned services. lazr.restful forced me to think about it
- # though, so this just hardcodes the version part of the resource URL
- # path to the first (i.e. numbered) version.
- self.version = self.webservice_config.active_versions[0]
- self.schema = ('https' if self.webservice_config.use_https else 'http')
- self.hostname = self.webservice_config.hostname
- self.port = self.webservice_config.port
-
-
-
-class FallbackURLMapper(BasicURLMapper):
- """Generic absolute url mapper."""
-
- def __call__(self):
- """Return the semi-hard-coded URL to the service root."""
- path = self._lookup(self.context)
- return '{0.schema}://{0.hostname}:{0.port}/{0.version}/{1}'.format(
- self, path)
-
- def _lookup(self, ob):
- """Return the path component for the object.
-
- :param ob: The object we're looking for.
- :type ob: anything
- :return: The path component.
- :rtype: string
- :raises KeyError: if no path component can be found.
- """
- log.debug('generic url mapper lookup: %s', ob)
- # Special cases.
- if isinstance(ob, AdminWebServiceApplication):
- return ''
- urls = {
- system: 'system',
- getUtility(IListManager): 'lists',
- getUtility(ISubscriptionService): 'members',
- }
- return urls[ob]
-
-
-
-class TopLevelURLMapper(BasicURLMapper):
- """A simple mapper for top level objects."""
-
- implements(IAbsoluteURL)
-
- format_string = None
-
- def __call__(self):
- """Return the hard-coded URL to the resource."""
- return self.format_string.format(self)
-
-
-class DomainURLMapper(TopLevelURLMapper):
- """Mapper of `IDomains` to `IAbsoluteURL`."""
-
- format_string = (
- '{0.schema}://{0.hostname}:{0.port}/{0.version}/'
- 'domains/{0.context.email_host}')
-
-
-class MailingListURLMapper(TopLevelURLMapper):
- """Mapper of `IMailingList` to `IAbsoluteURL`."""
-
- format_string = (
- '{0.schema}://{0.hostname}:{0.port}/{0.version}/'
- 'lists/{0.context.fqdn_listname}')
-
-
-class MemberURLMapper(TopLevelURLMapper):
- """Mapper of `IMember` to `IAbsoluteURL`."""
-
- def __init__(self, context, request):
- super(MemberURLMapper, self).__init__(context, request)
- # Use a shorted version of the MemberRole string.
- enum, dot, self.role = str(self.context.role).partition('.')
-
- format_string = (
- '{0.schema}://{0.hostname}:{0.port}/{0.version}/'
- 'lists/{0.context.mailing_list}/'
- '{0.role}/{0.context.address.address}')
diff --git a/src/mailman/rest/webservice.py b/src/mailman/rest/webservice.py
deleted file mode 100644
index c8aa470b9..000000000
--- a/src/mailman/rest/webservice.py
+++ /dev/null
@@ -1,54 +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/>.
-
-"""Module stuff."""
-
-from __future__ import absolute_import, unicode_literals
-
-__metaclass__ = type
-__all__ = [
- ]
-
-
-import json
-import hashlib
-import logging
-
-from restish import http, resource
-from wsgiref.simple_server import make_server as wsgi_server
-
-from zope.component import getUtility
-from zope.interface import implements
-
-from mailman.app.membership import delete_member
-from mailman.config import config
-from mailman.interfaces.address import InvalidEmailAddressError
-from mailman.interfaces.domain import (
- BadDomainSpecificationError, IDomain, IDomainManager)
-from mailman.interfaces.listmanager import (
- IListManager, ListAlreadyExistsError, NoSuchListError)
-from mailman.interfaces.mailinglist import IMailingList
-from mailman.interfaces.member import (
- AlreadySubscribedError, IMember, MemberRole)
-from mailman.interfaces.membership import ISubscriptionService
-
-
-COMMASPACE = ', '
-log = logging.getLogger('mailman.http')
-
-
-