On Wed, Apr 13, 2005 at 10:47:15AM -0400, Stephan Richter wrote: > On Thursday 07 April 2005 16:06, Philipp von Weitershausen wrote: > > > class MethodNotAllowed(Exception): > > > implements(IMethodNotAllowed) > > > > > > def __init__(self, object, request): > > > self.allow = [name for name, adapter > > > in zapi.getAdapters((object, request), Interface) > > > if hasattr(adapter, name)] > > > > > > def __str__(self): > > > return 'Allow: %s' % self.allow > > > > > > > > > class MethodNotAllowedView: > > > > > > def __init__(self, error, request): > > > self.error = error > > > self.request = request > > > > > > def __call__(self): > > > self.request.response.setHeader('Allow', ', > > > '.join(self.error.allow)) self.request.response.setStatus(405) > > > return 'Method Not Allowed' > > > > This looks good. I'm +1 on this. > > +1 I think this is a first good step. We have to think about the > special cases a bit harder.
The murky bit with this solution is that a defaultView adapter has to be registered for (IException, IHTTPRequest), as the error view lookup expects that in zopepublication.py line 296, otherwise a standard 500 error is returned to the client. Isn't default view name a browser-views-only concept? Anyway, I added this to the config, but I doubt this is the correct solution: <defaultView for="zope.interface.common.interfaces.IException" type="zope.publisher.interfaces.http.IHTTPRequest" name="GET" /> Any ideas? Albertas _______________________________________________ Zope3-dev mailing list Zope3firstname.lastname@example.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com