I would like to make the referrer visible in error tickets, so I can see where an erroneous link comes from. How do I do that?
I'm thinking of doing something like request['referer'] = request['wsgi']['environ']['HTTP_REFERER'], so that it shows up in the request. Where do I hook that in, so it gets added whenever an error occurs?
Errors and ticket generation are handled in /gluon/restricted.py. In particular, the request, response, and session details are added near the end of the snapshot function.
If you want to do some custom ticket handling without altering the framework code, look at this for some ideas.
If you just need to do some temporary debugging of a particular function, you could do a try...except
within the function, and upon exception, output the request object using the BEAUTIFY helper. Something like this:
def your_function():
try:
# YOUR FUNCTION CODE
except:
response.view = 'generic.html'
return dict(req=BEAUTIFY(request))
The above will display every item within the request object, including the referrer.
If you have more questions or would like to recommend changes to the error ticket functionality, I recommend asking on the web2py mailing list.