Web to py enterprise web framework - p 14
HTTP AND REDIRECT
115
4.11
HTTP and redirect
web2py defines only one new exception called HTTP. This exception can be raised anywhere in a model, a controller, or a view with the command:
1
raise HTTP(400, "my message")
It causes the control flow to jump away from the user’s code, back to web2py, and return an HTTP response like:
1 2 3 4 5 6 7 8 9
HTTP/1.1 400 BAD REQUEST Date: Sat, 05 Jul 2008 19:36:22 GMT Server: CherryPy/3.1.0beta3 WSGI Server Content-Type: text/html Via: 1.1 127.0.0.1:8000 Connection: close Transfer-Encoding: chunked my message
The first argument of HTTP is the HTTP status code. The second argument is the string...