diff options
| -rw-r--r-- | src/mailman/interfaces/listmanager.py | 3 | ||||
| -rw-r--r-- | src/mailman/rest/docs/lists.txt | 8 | ||||
| -rw-r--r-- | src/mailman/rest/publication.py | 10 | ||||
| -rw-r--r-- | src/mailman/rest/traverse.py | 8 |
4 files changed, 22 insertions, 7 deletions
diff --git a/src/mailman/interfaces/listmanager.py b/src/mailman/interfaces/listmanager.py index aeb564641..8a058eaa5 100644 --- a/src/mailman/interfaces/listmanager.py +++ b/src/mailman/interfaces/listmanager.py @@ -27,7 +27,7 @@ __all__ = [ from lazr.restful.declarations import ( - collection_default_content, export_as_webservice_collection, + collection_default_content, error_status, export_as_webservice_collection, export_factory_operation) from zope.interface import Interface, Attribute @@ -36,6 +36,7 @@ from mailman.interfaces.mailinglist import IMailingList +@error_status(400) class ListAlreadyExistsError(MailmanError): """Attempted to create a mailing list that already exists. diff --git a/src/mailman/rest/docs/lists.txt b/src/mailman/rest/docs/lists.txt index 51e8d6a3e..5b8c6bc5b 100644 --- a/src/mailman/rest/docs/lists.txt +++ b/src/mailman/rest/docs/lists.txt @@ -64,7 +64,9 @@ not exist. ... 'ws.op': 'new', ... 'fqdn_listname': 'test-three@example.org', ... }) - XXX + Traceback (most recent call last): + ... + HTTPError: HTTP Error 400: Bad Request Nor can you create a mailing list that already exists. @@ -72,4 +74,6 @@ Nor can you create a mailing list that already exists. ... 'ws.op': 'new', ... 'fqdn_listname': 'test-one@example.com', ... }) - XXX + Traceback (most recent call last): + ... + HTTPError: HTTP Error 400: Bad Request diff --git a/src/mailman/rest/publication.py b/src/mailman/rest/publication.py index 1b0e1ee00..2de9c8120 100644 --- a/src/mailman/rest/publication.py +++ b/src/mailman/rest/publication.py @@ -85,11 +85,21 @@ class Publication: """See `IPublication`.""" # Any in-progress transaction must be aborted. config.db.abort() + # Reproduce the behavior of ZopePublication by looking up a view + # for this exception. exception = exc_info[1] + # XXX BAW 2009-08-06 This should not be necessary. I need to register + # a view so that 404 will be returned for a NotFound. if isinstance(exception, NotFound): request.response.reset() request.response.setStatus(404) request.response.setResult('') + return + 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) diff --git a/src/mailman/rest/traverse.py b/src/mailman/rest/traverse.py index 2aef47709..ee8f3925c 100644 --- a/src/mailman/rest/traverse.py +++ b/src/mailman/rest/traverse.py @@ -17,6 +17,10 @@ """Traversal rules for the Mailman RESTful admin web service.""" +# XXX BAW 2009-08-06 Can we get rid of this module? It only seems to be used +# for NotFound traversals from the top level. See the failure in basic.txt if +# we remove this module. + from __future__ import absolute_import, unicode_literals __metaclass__ = type @@ -27,12 +31,8 @@ __all__ = [ from urllib import unquote -from zope.component import adapts from zope.interface import implements from zope.publisher.interfaces import IPublishTraverse, NotFound -from zope.publisher.interfaces.browser import IDefaultBrowserLayer - -from mailman.interfaces.rest import IHasGet |
