Sunday, February 04, 2007

python handy debug error tip

Here's a handy way to make debugging your scripts a little
easier. Just add this to your main script (before you do

def error():
if web.webapi.ctx.ip == '': web.debugerror()
else: origerror()
origerror = web.webapi.internalerror
web.webapi.internalerror = error

Add your IP address where it says. This will show detailed debug
output if an exception occurs, but only when the request is from your
IP address. Anyone else will get the usual "internal server error"
message. This is a convenient way to make your app securely
debuggable without having to manually switch back and forth between
debug/deploy modes every time you want to make a change.

No comments: