diff options
| author | Barry Warsaw | 2009-05-06 22:07:35 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2009-05-06 22:07:35 -0400 |
| commit | 374fbfef115c54f354b1fa823f0feef5c22c9d38 (patch) | |
| tree | c3bcae5dbd3a17b2eceb49baecca8a6c23cb797c /src | |
| parent | 3689c13b068735082c2dad9c6d4db1f4aacc3054 (diff) | |
| download | mailman-374fbfef115c54f354b1fa823f0feef5c22c9d38.tar.gz mailman-374fbfef115c54f354b1fa823f0feef5c22c9d38.tar.zst mailman-374fbfef115c54f354b1fa823f0feef5c22c9d38.zip | |
Diffstat (limited to 'src')
| -rw-r--r-- | src/mailman/queue/rest.py | 2 | ||||
| -rw-r--r-- | src/mailman/rest/docs/basic.txt | 13 | ||||
| -rw-r--r-- | src/mailman/rest/publication.py | 21 | ||||
| -rw-r--r-- | src/mailman/rest/webservice.py | 7 |
4 files changed, 33 insertions, 10 deletions
diff --git a/src/mailman/queue/rest.py b/src/mailman/queue/rest.py index 7ce1edb95..0728e6fbd 100644 --- a/src/mailman/queue/rest.py +++ b/src/mailman/queue/rest.py @@ -39,7 +39,7 @@ from mailman.rest.webservice import make_server class RESTRunner(Runner): def run(self): try: - make_server.serve_forever() + make_server().serve_forever() except KeyboardInterrupt: sys.exit(signal.SIGTERM) except select.error as (errcode, message): diff --git a/src/mailman/rest/docs/basic.txt b/src/mailman/rest/docs/basic.txt index a3ee56568..40934ec1f 100644 --- a/src/mailman/rest/docs/basic.txt +++ b/src/mailman/rest/docs/basic.txt @@ -23,6 +23,19 @@ returned. self_link: https://localhost:8001/3.0/system +Non-existent links +------------------ + +when you try to access an admin link that doesn't exist, you get the +appropriate HTTP 404 Not Found error. + + >>> from urllib2 import urlopen + >>> urlopen('http://localhost:8001/3.0/does-not-exist') + Traceback (most recent call last): + ... + HTTPError: HTTP Error 404: Not Found + + Cleanup ------- diff --git a/src/mailman/rest/publication.py b/src/mailman/rest/publication.py index bc57bdd58..1f3fa74b5 100644 --- a/src/mailman/rest/publication.py +++ b/src/mailman/rest/publication.py @@ -34,6 +34,7 @@ from zope.publisher.interfaces import IPublication, NotFound from zope.publisher.publish import mapply from zope.security.management import endInteraction, newInteraction +from mailman.config import config from mailman.interfaces.rest import IResolvePathNames @@ -66,28 +67,30 @@ class Publication: return ob.get(name) def afterTraversal(self, request, ob): + """See `IPublication`.""" pass def callObject(self, request, ob): - """Call the object, returning the result.""" + """See `IPublication`.""" # XXX Bad hack. from zope.security.proxy import removeSecurityProxy ob = removeSecurityProxy(ob) return mapply(ob, request.getPositionalArguments(), request) def afterCall(self, request, ob): + """See `IPublication`.""" pass - 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. + def handleException(self, application, request, exc_info, + retry_allowed=True): + """See `IPublication`.""" + # Any in-progress transaction must be aborted. + config.db.abort() exception = exc_info[1] - view = queryMultiAdapter((exception, request), name='index.html') - if view is not None: - exc_info = None + if isinstance(exception, NotFound): request.response.reset() - request.response.setResult(view()) + request.response.setStatus(404) + request.response.setResult('') else: traceback.print_exception(*exc_info) diff --git a/src/mailman/rest/webservice.py b/src/mailman/rest/webservice.py index bf1012203..c6f0da2ef 100644 --- a/src/mailman/rest/webservice.py +++ b/src/mailman/rest/webservice.py @@ -28,6 +28,13 @@ __all__ = [ import logging +import warnings + +# lazr.restful uses the sha module, but that's deprecated in Python 2.6 in +# favor of the hashlib module. +warnings.filterwarnings( + 'ignore', category=DeprecationWarning, module='lazr.restful._resource') + # Don't use wsgiref.simple_server.make_server() because we need to override # BaseHTTPRequestHandler.log_message() so that logging output will go to the |
