I'm using web.py 0.3 / apache2 / mod_wsgi and the cgitb module doesn't seem to work out of the box (I still just get 'internal server error' from web.py and the usual output goes to apache's error_log). The web.py install guide suggested a workaround which didn't work for me - I could probably hack it into working, but is there something better (perhaps designed for web.py or wsgi) that I should use instead?
3 Answers
Set web.config.debug = True before creating your app. That enables debug error, which contains the stack trace of exception along with values of locals.
1 Comment
When debugging apache2 and web.py, it's usually good to catch errors in the apache error log. When you get an internal server error, for instance, it means nothing was returned for whatever reason by your app.
On Linux, I just watch the error log in a separate terminal...
tail -f /var/log/apache2/error_log
or
tail -f /var/log/httpd/error_log
or something depending on your distribution. If there's a typo or error message or what not, you'll get the typical python stack trace in your error log even if you get an internal server error in your browser.
1 Comment
Lack of cgitb was really slowing me down, too. This did it for me:
try: Output+=TroublesomeScript(etc)
except: import traceback; Output+=str(traceback.format_exc())
You can beautify the output if you like but this should give you the information you need for debugging. You can also just output sys.exc_info(), but the traceback module seems to be recommended.