On Sun, May 6, 2012 at 11:15 PM, Dom <[email protected]> wrote:
> Hi List!
>
> How do I set the "Allow" header for the "405 Method Not Allowed"
> return code with the web.webapi.NoMethod() call?
> This is mandatory as defined in RFC2616: "(...)The response MUST
> include an Allow header containing a list of valid methods for the
> requested resource. (...)"
>
> Why is there no option "headers" like in other web.webapi methods?
>
> And why is there a type web.webapi.nomethod() and
> web.webapi.NoMethod() isn't that somewhat redundant and confusing for
> the users?
>
> I've worked around that by using:
>
> raise web.webapi.HTTPError('405 Method Not Allowed',headers={'Allow':
> 'GET, POST'})
>
> instead of:
>
> raise web.webapi.NoMethod()
>
> Or am I completely wrong: Don't I use this as it is intended?

You can call it as:

raise web.nomethod(cls=class_object)

The nomethod will look at available method in the class_object and
sets the Allow header accordingly.

There no way to specify list of allowed methods explicitly. If you
want to do that, one work-around is to call it as:

raise web.nomethod(cls=web.storage(GET=None, POST=None))

Anand

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to