------------------------------------------------------------
revno: 6717
committer: Barry Warsaw <[email protected]>
branch nick: restful
timestamp: Thu 2009-04-02 15:19:00 -0500
message:
  Checking pointing all the ZCA and restful wiring that I really don't
  understand.  Cargo culting FTW.
added:
  src/mailman/rest/configuration.py
  src/mailman/rest/configure.zcml
  src/mailman/rest/initialize.py
  src/mailman/rest/publication.py
  src/mailman/rest/security.py
modified:
  buildout.cfg
  setup.py
  src/mailman/config/schema.cfg
  src/mailman/interfaces/system.py
  src/mailman/rest/root.py

=== modified file 'buildout.cfg'
--- buildout.cfg        2009-04-01 21:22:40 +0000
+++ buildout.cfg        2009-04-02 20:19:00 +0000
@@ -10,15 +10,7 @@
 recipe = zc.recipe.egg
 interpreter = py
 eggs =
-    argparse
-    lazr.config
-    lazr.delegates
-    lazr.restful
-    locknix
     mailman
-    munepy
-    storm
-    zope.interface
 
 [tags]
 recipe = z3c.recipe.tag:tags

=== modified file 'setup.py'
--- setup.py    2009-03-10 04:06:16 +0000
+++ setup.py    2009-04-02 20:19:00 +0000
@@ -88,11 +88,14 @@
         'console_scripts' : list(scripts),
         },
     install_requires = [
+        'argparse',
         'lazr.config',
         'lazr.delegates',
+        'lazr.restful',
         'locknix',
         'munepy',
         'storm',
+        'zope.schema',
         'zope.interface',
         ],
     setup_requires = [

=== modified file 'src/mailman/config/schema.cfg'
--- src/mailman/config/schema.cfg       2009-03-10 04:06:16 +0000
+++ src/mailman/config/schema.cfg       2009-04-02 20:19:00 +0000
@@ -207,6 +207,21 @@
 [logging.vette]
 
 
+[webservice]
+# The hostname at which admin web service resources are exposed.
+hostname: localhost
+
+# Whether or not requests to the web service are secured through SSL.
+use_https: no
+
+# Default view permission for the admin web service.
+view_permission: zope.Public
+
+# Whether or not to show tracebacks in an HTTP response for a request that
+# raised an exception.
+show_tracebacks: yes
+
+
 [domain.master]
 # Site-wide domain defaults.  To configure an individual
 # domain, add a [domain.example_com] section with the overrides.

=== modified file 'src/mailman/interfaces/system.py'
--- src/mailman/interfaces/system.py    2009-04-01 21:22:40 +0000
+++ src/mailman/interfaces/system.py    2009-04-02 20:19:00 +0000
@@ -26,6 +26,7 @@
 
 
 from lazr.restful.declarations import export_as_webservice_entry, exported
+from zope.interface import Interface
 from zope.schema import TextLine
 
 from mailman.i18n import _

=== added file 'src/mailman/rest/configuration.py'
--- src/mailman/rest/configuration.py   1970-01-01 00:00:00 +0000
+++ src/mailman/rest/configuration.py   2009-04-02 20:19:00 +0000
@@ -0,0 +1,74 @@
+# Copyright (C) 2009 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.restful.interfaces import IWebServiceConfiguration
+
+from mailman.config import config
+from mailman.rest.publication import AdminWebServicePublication
+from mailman.rest.root import AdminWebServiceRootResource
+from mailman.version import VERSION
+
+
+
+class AdminWebServiceConfiguration:
+    """A configuration object for the Mailman admin web service."""
+
+    implements(IWebServiceConfiguration)
+
+    @property
+    def view_permission(self):
+        return config.webservice.view_permission
+
+    path_override = 'admin'
+
+    @property
+    def use_https(self):
+        """See `IWebServiceConfiguration`."""
+        return config.webservice.use_https
+
+    # This should match the major.minor Mailman version.
+    service_version_uri_prefix = '3.0'
+    code_revision = VERSION
+
+    @property
+    def show_tracebacks(self):
+        """See `IWebServiceConfiguration`."""
+        return config.webservice.show_tracebacks
+        
+    default_batch_size = 50
+    max_batch_size = 300
+
+    def createRequest(self, body_instream, environ):
+        """See `IWebServiceConfiguration`."""
+        request = AdminWebServiceRequest(body_instream, environ)
+        request.setPublication(
+            AdminWebServicePublication(AdminWebServiceRootResource())
+        return request
+
+    def get_request_user(self):
+        """See `IWebServiceConfiguration`."""
+        return None

=== added file 'src/mailman/rest/configure.zcml'
--- src/mailman/rest/configure.zcml     1970-01-01 00:00:00 +0000
+++ src/mailman/rest/configure.zcml     2009-04-02 20:19:00 +0000
@@ -0,0 +1,17 @@
+<!-- -*- xml -*- -->
+<configure
+    xmlns="http://namespaces.zope.org/zope";
+    xmlns:webservice="http://namespaces.canonical.com/webservice";>
+
+  <webservice:register module="mailman.interfaces.rest" />
+
+  <adapter factory="mailman.rest.traversal.Traverse" />
+
+  <adapter factory="mailman.rest.root.AdminWebServiceRootAbsoluteURL" />
+
+  <adapter
+    factory="mailman.rest.root.AdminWebServiceRootAbsoluteURL"
+    name="absolute_url"
+    />
+
+</configure>

=== added file 'src/mailman/rest/initialize.py'
--- src/mailman/rest/initialize.py      1970-01-01 00:00:00 +0000
+++ src/mailman/rest/initialize.py      2009-04-02 20:19:00 +0000
@@ -0,0 +1,34 @@
+# Copyright (C) 2009 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/>.
+
+"""Admin web service initialization."""
+
+from __future__ import absolute_import, unicode_literals
+
+__metaclass__ = type
+__all__ = [
+    'initialize',
+    ]
+
+
+from zope.configuration import xmlconfig
+
+
+
+def initialize():
+    """Initialize the admin web service and the Zope Component Architecture."""
+    xmlconfig.file('mailman', 'mailman.rest')

=== added file 'src/mailman/rest/publication.py'
--- src/mailman/rest/publication.py     1970-01-01 00:00:00 +0000
+++ src/mailman/rest/publication.py     2009-04-02 20:19:00 +0000
@@ -0,0 +1,29 @@
+# Copyright (C) 2009 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__ = [
+    ]
+
+
+
+class WebServiceTestPublication(WebServicePublicationMixin, TestPublication):
+    """Test publication that mixes in the necessary web service stuff."""

=== modified file 'src/mailman/rest/root.py'
--- src/mailman/rest/root.py    2009-04-02 00:02:49 +0000
+++ src/mailman/rest/root.py    2009-04-02 20:19:00 +0000
@@ -21,19 +21,25 @@
 
 __metaclass__ = type
 __all__ = [
-    'AdminServiceRootResource',
+    'AdminWebServiceRootResource',
+    'AdminWebServiceRootAbsoluteURL',
     ]
 
 
 from lazr.restful import ServiceRootResource
+from zope.component import adapts
 from zope.interface import implements
+from zope.publisher.interfaces.browser import IDefaultBrowserLayer
+from zope.traversing.browser.interfaces import IAbsoluteURL
 
+from mailman.config import config
 from mailman.core.system import system
 from mailman.interfaces.rest import IHasGet
+from mailman.rest.configuration import AdminWebServiceConfiguration
 
 
 
-class AdminServiceRootResource(ServiceRootResource):
+class AdminWebServiceRootResource(ServiceRootResource):
     """The root of the Mailman RESTful admin web service."""
 
     implements(IHasGet)
@@ -44,3 +50,23 @@
             'sys': system,
             }
         return top_level.get(name)
+
+
+class AdminWebServiceRootAbsoluteURL:
+    """A basic implementation of `IAbsoluteURL` for the root object."""
+
+    implements(IAbsoluteURL)
+    adapts(AdminWebServiceRootResource, IDefaultBrowserLayer)
+
+    def __init__(self, context, request):
+        """Initialize with respect to a context and request."""
+        self.webservice_config = AdminWebServiceConfiguration()
+        self.version = webservice_config.service_version_uri_prefix
+        self.schema = ('https' if self.webservice_config.use_https else 'http')
+        self.hostname = config.webservice.hostname
+
+    def __str__(self):
+        """Return the semi-hard-coded URL to the service root."""
+        return '{0.schema}://{0.hostname}/{0.version}'.format(self)
+
+    __call__ = __str__

=== added file 'src/mailman/rest/security.py'
--- src/mailman/rest/security.py        1970-01-01 00:00:00 +0000
+++ src/mailman/rest/security.py        2009-04-02 20:19:00 +0000
@@ -0,0 +1,37 @@
+# Copyright (C) 2009 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/>.
+
+"""Default security policy for the admin web service."""
+
+from __future__ import absolute_import, unicode_literals
+
+__metaclass__ = type
+__all__ = [
+    'AdminWebServiceSecurityPolicy',
+    ]
+
+
+from zope.security.simplepolicies import PermissiveSecurityPolicy
+
+
+
+class AdminWebServiceSecurityPolicy(PermissiveSecurityPolicy):
+    """A very basic wide-open security policy."""
+
+    def checkPermission(self, permission, object):
+        """By default, allow all access!"""
+        return True



--
Primary development focus
https://code.launchpad.net/~mailman-coders/mailman/3.0

Your team Mailman Checkins is subscribed to branch lp:mailman.
To unsubscribe from this branch go to 
https://code.launchpad.net/~mailman-coders/mailman/3.0/+edit-subscription.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to