Thank you for your answer. 

I missed the "cls" parameter. And also did I miss the fact, that web.py handles 
not existing methods and the 405 automatically if they simply aren't defined in 
the class. I thought I have to implement them and handle the HTTP status 405 on 
my own in them...

Sorry to bother you!

Kind regards,
Dom

Am 07.05.2012 um 02:38 schrieb Anand Chitipothu <anandol...@gmail.com>:

> On Sun, May 6, 2012 at 11:15 PM, Dom <dominik.fischer...@googlemail.com> 
> 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 webpy@googlegroups.com.
> To unsubscribe from this group, send email to 
> webpy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/webpy?hl=en.
> 

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

Reply via email to