Fred Drake | 6e70e8b | 2001-12-04 22:47:42 +0000 | [diff] [blame^] | 1 | \section{\module{cgitb} --- |
| 2 | Traceback manager for CGI scripts} |
| 3 | |
| 4 | \declaremodule{standard}{cgitb} |
| 5 | \modulesynopsis{Configurable traceback handler for CGI scripts.} |
| 6 | \moduleauthor{Ka Ping Yee}{ping@lfw.org} |
| 7 | \sectionauthor{Fred L. Drake, Jr.}{fdrake@acm.org} |
| 8 | |
| 9 | \index{CGI!tracebacks} |
| 10 | \index{traceback!in CGI scripts} |
| 11 | |
| 12 | The \module{cgitb} module provides a special exception handler for CGI |
| 13 | scripts. Using this module, an exception raised and left uncaught in |
| 14 | a CGI script can be presented as colorized HTML in the user's Web |
| 15 | browser. The options to the \function{enable()} function can be used |
| 16 | to control whether the colorized traceback is presented and whether |
| 17 | the traceback is logged to a file for later analysis. |
| 18 | |
| 19 | |
| 20 | \begin{funcdesc}{enable}{\optional{display\optional{, logdir\optional{, |
| 21 | context}}}} |
| 22 | This function causes the \module{cgitb} module to take over the |
| 23 | interpreters default handling for exceptions that propogate out of |
| 24 | the top level of a script. The causes \module{cgitb} to set the |
| 25 | value of \code{\refmodule{sys}.excepthook}. |
| 26 | |
| 27 | The optional argument \var{display} defaults to true and can be set |
| 28 | to false to suppress sending the traceback to the browser. |
| 29 | \var{logdir}, if given, should be a directory to cause tracebacks to |
| 30 | be written to files there; by default tracebacks will not be written |
| 31 | to files. \var{context} is the number of lines of context around |
| 32 | the offending line in a traceback display; this defaults to |
| 33 | \code{5}. |
| 34 | \end{funcdesc} |
| 35 | |
| 36 | \begin{funcdesc}{handler}{\optional{info}} |
| 37 | This function handles an exception using the default settings. This |
| 38 | can be used when you've caught an exception and want to report it |
| 39 | using \module{cgitb}, but need to continue processing. |
| 40 | \end{funcdesc} |