Could be a bug. Please file an issue on Github.
On Thursday, February 9, 2017 at 7:33:30 PM UTC-5, MDSIII wrote:
>
> I have tried implementing routes_onerror in routes.py like this:
>
> routes_onerror = [
> (r'welcome/500', r'/welcome/default/on500'),
> (r'welcome/400', r'/welcome/default/on400')
> ]
>
> and added these functions in default.py controller:
>
> def raise500():
>
> raise ValueError('random internal error')
>
> def raise400():
>
> print "in raise 400"
> raise HTTP(400, 'not the droids')
>
> def on500():
>
> print "alternate handler for 500"
> return "something useful, maybe ticket number encoded in json?"
>
> def on400():
>
> print "in on 400"
> return "handler for 400s"
>
> def myform():
> form = FORM('blah', INPUT(_name='name'),
> INPUT(_type='submit'), _action=URL('raise400'))
>
> return response.render({'form': form})
>
>
> If I visit the "raise" urls from a browser everything works as expected
> (although I thought I'd see redirects in DevTools:network and I'm not
> seeing that, just immediate responses). Even the response status is correct.
> But if I post from a form (or use python requests lib) then the response
> is status 500 and response text = "Server Error"
> Also I get this traceback from the console running the web2py server:
>
> ERROR:Rocket.Errors.Thread-2:Traceback (most recent call last):
>
> File "D:\web2py\gluon\rocket.py", line 1337, in run
> self.run_app(conn)
>
> File "D:\web2py\gluon\rocket.py", line 1838, in run_app
> output = self.app(environ, self.start_response)
>
> File "D:\web2py\gluon\main.py", line 653, in app_with_logging
> ret[0] = wsgiapp(environ, responder2)
>
> File "D:\web2py\gluon\main.py", line 564, in wsgibase
> return wsgibase(new_environ, responder)
>
> File "D:\web2py\gluon\main.py", line 534, in wsgibase
> if request.body:
>
> File "D:\web2py\gluon\globals.py", line 281, in body
> raise HTTP(400, "Bad Request - HTTP body is incomplete")
>
> HTTP: 400 BAD REQUEST
>
> Am I doing something wrong or is routes on error not supposed to handle
> POST?
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.