------------------------------------------------------------
revno: 6725
committer: Barry Warsaw <[email protected]>
branch nick: rest
timestamp: Wed 2009-05-06 22:07:35 -0400
message:
  Several RESTful updates.
  
  * Fix a typo in the runner
  * Add support for 404 Not Found exceptions
  * Suppress sha module deprecation warnings from lazr.restful
modified:
  src/mailman/queue/rest.py
  src/mailman/rest/docs/basic.txt
  src/mailman/rest/publication.py
  src/mailman/rest/webservice.py

=== modified file 'src/mailman/queue/rest.py'
--- src/mailman/queue/rest.py   2009-05-04 15:05:51 +0000
+++ src/mailman/queue/rest.py   2009-05-07 02:07:35 +0000
@@ -39,7 +39,7 @@
 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):

=== modified file 'src/mailman/rest/docs/basic.txt'
--- src/mailman/rest/docs/basic.txt     2009-05-04 15:33:10 +0000
+++ src/mailman/rest/docs/basic.txt     2009-05-07 02:07:35 +0000
@@ -23,6 +23,19 @@
     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
 -------
 

=== modified file 'src/mailman/rest/publication.py'
--- src/mailman/rest/publication.py     2009-05-02 22:07:38 +0000
+++ src/mailman/rest/publication.py     2009-05-07 02:07:35 +0000
@@ -34,6 +34,7 @@
 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 @@
         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)
 

=== modified file 'src/mailman/rest/webservice.py'
--- src/mailman/rest/webservice.py      2009-05-04 15:33:10 +0000
+++ src/mailman/rest/webservice.py      2009-05-07 02:07:35 +0000
@@ -28,6 +28,13 @@
 
 
 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



--
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