Re: [Zope3-dev] Re: HTTP 405: Method Not Allowed

2005-04-15 Thread Albertas Agejevas
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:

  

Any ideas?

Albertas
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] Re: HTTP 405: Method Not Allowed

2005-04-13 Thread Stephan Richter
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.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com