------------------------------------------------------------
revno: 6777
committer: Barry Warsaw <[email protected]>
branch nick: 3.0
timestamp: Mon 2009-08-17 17:02:02 -0400
message:
  Use an adapter instead of custom handleException() code to return a 404
  instead of a 500 for NotFound errors.
modified:
  src/mailman/rest/configure.zcml
  src/mailman/rest/publication.py


--
lp:mailman
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.
=== modified file 'src/mailman/rest/configure.zcml'
--- src/mailman/rest/configure.zcml	2009-08-17 18:40:03 +0000
+++ src/mailman/rest/configure.zcml	2009-08-17 21:02:02 +0000
@@ -41,6 +41,14 @@
     factory="mailman.rest.urls.MailingListURLMapper"
     />
 
+  <adapter
+    for="zope.publisher.interfaces.NotFound
+         lazr.restful.simple.Request"
+    provides="zope.interface.Interface"
+    factory="lazr.restful.error.NotFoundView"
+    name="index.html"
+    />
+
   <utility
     factory="mailman.rest.configuration.AdminWebServiceConfiguration"
     provides="lazr.restful.interfaces.IWebServiceConfiguration">

=== modified file 'src/mailman/rest/publication.py'
--- src/mailman/rest/publication.py	2009-08-17 17:39:41 +0000
+++ src/mailman/rest/publication.py	2009-08-17 21:02:02 +0000
@@ -56,16 +56,8 @@
         """See `IPublication`."""
         # Any in-progress transaction must be aborted.
         config.db.abort()
-        # 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.
-        exception = exc_info[1]
-        if isinstance(exception, NotFound):
-            request.response.reset()
-            request.response.setStatus(404)
-            request.response.setResult('')
-        else:
-            super(AdminWebServicePublication, self).handleException(
-                application, request, exc_info, retry_allowed)
+        super(AdminWebServicePublication, self).handleException(
+            application, request, exc_info, retry_allowed)
 
     def endRequest(self, request, ob):
         """Ends the interaction."""

_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to