March 2003
Intermediate to advanced
656 pages
39h 30m
English
enable
enable(display=True,logdir=None,context=5)
Installs an exception hook, via sys.excepthook, to
diagnose propagated exceptions. The hook displays the exception
traceback on the browser if display is
true. The hook logs the exception traceback to a file in directory
logdir if
logdir is not None. In
the traceback, the hook shows context
lines of source code per frame.
In practice, you can start all of your CGI scripts with:
import cgitb cgitb.enable( )
and be assured of good error reporting to the browser with minimal
effort on your part. Of course, when you don’t want
users of your page to see Python tracebacks from your scripts on
their browsers, you can call
cgitb(False,'/my/log/dir') and get the error
reports, with exception tracebacks, as files in directory
/my/log/dir instead.
Read now
Unlock full access