------------------------------------------------------------
revno: 6719
committer: Barry Warsaw <[email protected]>
branch nick: restful
timestamp: Thu 2009-04-02 18:43:19 -0500
message:
Make things import.
modified:
src/mailman/rest/publication.py
src/mailman/rest/root.py
=== modified file 'src/mailman/rest/publication.py'
--- src/mailman/rest/publication.py 2009-04-02 20:44:25 +0000
+++ src/mailman/rest/publication.py 2009-04-02 23:43:19 +0000
@@ -21,12 +21,106 @@
__metaclass__ = type
__all__ = [
+ 'AdminWebServicePublication',
]
+import traceback
+
from lazr.restful.publisher import WebServicePublicationMixin
-
-
-
-class AdminWebServiceTestPublication(WebServicePublicationMixin,
TestPublication):
- """Test publication that mixes in the necessary web service stuff."""
+from zope.component import getUtility, queryMultiAdapter
+from zope.interface import implements
+from zope.publisher.interfaces import IPublication, IPublishTraverse, NotFound
+from zope.publisher.publish import mapply
+from zope.security.checker import ProxyFactory
+from zope.security.management import endInteraction, newInteraction
+
+
+
+class Publication:
+ """Very simple implementation of `IPublication`.
+
+ The object pass to the constructor is returned by getApplication().
+ """
+ implements(IPublication)
+
+ def __init__(self, application):
+ """Create the test publication.
+
+ The object at which traversal should start is passed as parameter.
+ """
+ self.application = application
+
+ def beforeTraversal(self, request):
+ """Sets the request as the current interaction.
+
+ (It also ends any previous interaction, that's convenient when
+ tests don't go through the whole request.)
+ """
+ endInteraction()
+ newInteraction(request)
+
+ def getApplication(self, request):
+ """Returns the application passed to the constructor."""
+ return self.application
+
+ def callTraversalHooks(self, request, ob):
+ """Does nothing."""
+
+ def traverseName(self, request, ob, name):
+ """Traverse by looking at an `IPublishTraverse` adapter.
+
+ The object is security wrapped.
+ """
+ # XXX flacoste 2009/03/06 bug=338831. This is copied from
+ # zope.app.publication.publicationtraverse.PublicationTraverse.
+ # This should really live in zope.publisher, we are copying because
+ # we don't want to depend on zope.app stuff.
+ # Namespace support was dropped.
+ if name == '.':
+ return ob
+
+ if IPublishTraverse.providedBy(ob):
+ ob2 = ob.publishTraverse(request, name)
+ else:
+ # self is marker.
+ adapter = queryMultiAdapter(
+ (ob, request), IPublishTraverse, default=self)
+ if adapter is not self:
+ ob2 = adapter.publishTraverse(request, name)
+ else:
+ raise NotFound(ob, name, request)
+
+ return ProxyFactory(ob2)
+
+ def afterTraversal(self, request, ob):
+ """Does nothing."""
+
+ def callObject(self, request, ob):
+ """Call the object, returning the result."""
+ return mapply(ob, request.getPositionalArguments(), request)
+
+ def afterCall(self, request, ob):
+ """Does nothing."""
+
+ def handleException(self, object, request, exc_info, retry_allowed=1):
+ """Prints the exception."""
+ # Reproduce the behavior of ZopePublication by looking up a view
+ # for this exception.
+ exception = exc_info[1]
+ view = queryMultiAdapter((exception, request), name='index.html')
+ if view is not None:
+ exc_info = None
+ request.response.reset()
+ request.response.setResult(view())
+ else:
+ traceback.print_exception(*exc_info)
+
+ def endRequest(self, request, ob):
+ """Ends the interaction."""
+ endInteraction()
+
+
+
+class AdminWebServicePublication(WebServicePublicationMixin, Publication):
+ """A publication that mixes in the necessary web service stuff."""
=== modified file 'src/mailman/rest/root.py'
--- src/mailman/rest/root.py 2009-04-02 20:19:00 +0000
+++ src/mailman/rest/root.py 2009-04-02 23:43:19 +0000
@@ -35,7 +35,6 @@
from mailman.config import config
from mailman.core.system import system
from mailman.interfaces.rest import IHasGet
-from mailman.rest.configuration import AdminWebServiceConfiguration
@@ -60,6 +59,8 @@
def __init__(self, context, request):
"""Initialize with respect to a context and request."""
+ # Avoid circular imports.
+ from mailman.rest.configuration import AdminWebServiceConfiguration
self.webservice_config = AdminWebServiceConfiguration()
self.version = webservice_config.service_version_uri_prefix
self.schema = ('https' if self.webservice_config.use_https else 'http')
--
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