On Saturday, January 27, 2018 at 6:44:22 AM UTC-5, Alfonso Serra wrote:
>
> what do i need to return at an error handler controller to get the same as 
> web2py does by default? Let me ellaborate:
>
> I have implemented "routes on error" at routes.py like:
>
> routes_onerror = [
>     (r"*/*", r"/error")
> ]
>
> so any error goes through "/myapp/controllers/error.py" (note i have 
> removed the appname from any route, thats not the issue).
>
> on errors.py i have some code for development only: (skip the tickets 
> system)
> def index():
>     
>     import mechanize
>     url = "http://127.0.0.1/admin/default/ticket/"; + request.vars.ticket
>     br = mechanize.Browser()
>     br.set_handle_robots(False)
>     resp = br.open(url)
>     br.form = list(br.forms())[0]
>             
>     br.form['password'] = "1234"
>     req = br.submit()
>     return req.read()
>
> If i write this on a random controller:
> raise HTTP(400, "cant do it")
>
> i would like that response to get to the browser instead the one at 
> errors.py so:
>
> what do i need to return at errors.py so i get this 400 error with the 
> message?
>

See https://groups.google.com/d/msg/web2py/Mg5kK2AuoMQ/VQM7Rr8jBAAJ for 
some ideas. The general idea is to set some flag when you raise your own 
errors (e.g., using special error codes, adding a key/value to the WSGI 
environment, etc.), and then look for that flag in your error handler in 
order to take the appropriate action there.

Anthony

-- 
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.

Reply via email to