Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / html / python / lib / module-cgitb.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="next" href="module-urllib.html" />
13<link rel="prev" href="module-cgi.html" />
14<link rel="parent" href="internet.html" />
15<link rel="next" href="module-urllib.html" />
16<meta name='aesop' content='information' />
17<title>11.3 cgitb -- Traceback manager for CGI scripts</title>
18</head>
19<body>
20<DIV CLASS="navigation">
21<div id='top-navigation-panel' xml:id='top-navigation-panel'>
22<table align="center" width="100%" cellpadding="0" cellspacing="2">
23<tr>
24<td class='online-navigation'><a rel="prev" title="11.2.10 Common problems and"
25 href="node479.html"><img src='../icons/previous.png'
26 border='0' height='32' alt='Previous Page' width='32' /></A></td>
27<td class='online-navigation'><a rel="parent" title="11. Internet Protocols and"
28 href="internet.html"><img src='../icons/up.png'
29 border='0' height='32' alt='Up One Level' width='32' /></A></td>
30<td class='online-navigation'><a rel="next" title="11.4 urllib "
31 href="module-urllib.html"><img src='../icons/next.png'
32 border='0' height='32' alt='Next Page' width='32' /></A></td>
33<td align="center" width="100%">Python Library Reference</td>
34<td class='online-navigation'><a rel="contents" title="Table of Contents"
35 href="contents.html"><img src='../icons/contents.png'
36 border='0' height='32' alt='Contents' width='32' /></A></td>
37<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
38 border='0' height='32' alt='Module Index' width='32' /></a></td>
39<td class='online-navigation'><a rel="index" title="Index"
40 href="genindex.html"><img src='../icons/index.png'
41 border='0' height='32' alt='Index' width='32' /></A></td>
42</tr></table>
43<div class='online-navigation'>
44<b class="navlabel">Previous:</b>
45<a class="sectref" rel="prev" href="node479.html">11.2.10 Common problems and</A>
46<b class="navlabel">Up:</b>
47<a class="sectref" rel="parent" href="internet.html">11. Internet Protocols and</A>
48<b class="navlabel">Next:</b>
49<a class="sectref" rel="next" href="module-urllib.html">11.4 urllib </A>
50</div>
51<hr /></div>
52</DIV>
53<!--End of Navigation Panel-->
54
55<H1><A NAME="SECTION0013300000000000000000">
5611.3 <tt class="module">cgitb</tt> --
57 Traceback manager for CGI scripts</A>
58</H1>
59
60<P>
61<A NAME="module-cgitb"></A>
62
63<P>
64
65<span class="versionnote">New in version 2.2.</span>
66
67<a id='l2h-3182' xml:id='l2h-3182'></a>
68
69<P>
70The <tt class="module">cgitb</tt> module provides a special exception handler for Python
71scripts. (Its name is a bit misleading. It was originally designed to
72display extensive traceback information in HTML for CGI scripts. It was
73later generalized to also display this information in plain text.) After
74this module is activated, if an uncaught exception occurs, a detailed,
75formatted report will be displayed. The report
76includes a traceback showing excerpts of the source code for each level,
77as well as the values of the arguments and local variables to currently
78running functions, to help you debug the problem. Optionally, you can
79save this information to a file instead of sending it to the browser.
80
81<P>
82To enable this feature, simply add one line to the top of your CGI script:
83
84<P>
85<div class="verbatim"><pre>
86import cgitb; cgitb.enable()
87</pre></div>
88
89<P>
90The options to the <tt class="function">enable()</tt> function control whether the
91report is displayed in the browser and whether the report is logged
92to a file for later analysis.
93
94<P>
95<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
96 <td><nobr><b><tt id='l2h-3178' xml:id='l2h-3178' class="function">enable</tt></b>(</nobr></td>
97 <td><var></var><big>[</big><var>display</var><big>[</big><var>, logdir</var><big>[</big><var>,
98 context</var><big>[</big><var>, format</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
99<dd>
100 This function causes the <tt class="module">cgitb</tt> module to take over the
101 interpreter's default handling for exceptions by setting the
102 value of <code><tt class="module"><a href="module-sys.html">sys</a></tt>.excepthook</code>.
103 <a id='l2h-3180' xml:id='l2h-3180'></a>
104<P>
105The optional argument <var>display</var> defaults to <code>1</code> and can be set
106 to <code>0</code> to suppress sending the traceback to the browser.
107 If the argument <var>logdir</var> is present, the traceback reports are
108 written to files. The value of <var>logdir</var> should be a directory
109 where these files will be placed.
110 The optional argument <var>context</var> is the number of lines of
111 context to display around the current line of source code in the
112 traceback; this defaults to <code>5</code>.
113 If the optional argument <var>format</var> is <code>"html"</code>, the output is
114 formatted as HTML. Any other value forces plain text output. The default
115 value is <code>"html"</code>.
116</dl>
117
118<P>
119<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
120 <td><nobr><b><tt id='l2h-3181' xml:id='l2h-3181' class="function">handler</tt></b>(</nobr></td>
121 <td><var></var><big>[</big><var>info</var><big>]</big><var></var>)</td></tr></table></dt>
122<dd>
123 This function handles an exception using the default settings
124 (that is, show a report in the browser, but don't log to a file).
125 This can be used when you've caught an exception and want to
126 report it using <tt class="module">cgitb</tt>. The optional <var>info</var> argument
127 should be a 3-tuple containing an exception type, exception
128 value, and traceback object, exactly like the tuple returned by
129 <code><tt class="module"><a href="module-sys.html">sys</a></tt>.exc_info()</code>. If the <var>info</var> argument
130 is not supplied, the current exception is obtained from
131 <code><tt class="module"><a href="module-sys.html">sys</a></tt>.exc_info()</code>.
132</dl>
133
134<DIV CLASS="navigation">
135<div class='online-navigation'>
136<p></p><hr />
137<table align="center" width="100%" cellpadding="0" cellspacing="2">
138<tr>
139<td class='online-navigation'><a rel="prev" title="11.2.10 Common problems and"
140 href="node479.html"><img src='../icons/previous.png'
141 border='0' height='32' alt='Previous Page' width='32' /></A></td>
142<td class='online-navigation'><a rel="parent" title="11. Internet Protocols and"
143 href="internet.html"><img src='../icons/up.png'
144 border='0' height='32' alt='Up One Level' width='32' /></A></td>
145<td class='online-navigation'><a rel="next" title="11.4 urllib "
146 href="module-urllib.html"><img src='../icons/next.png'
147 border='0' height='32' alt='Next Page' width='32' /></A></td>
148<td align="center" width="100%">Python Library Reference</td>
149<td class='online-navigation'><a rel="contents" title="Table of Contents"
150 href="contents.html"><img src='../icons/contents.png'
151 border='0' height='32' alt='Contents' width='32' /></A></td>
152<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
153 border='0' height='32' alt='Module Index' width='32' /></a></td>
154<td class='online-navigation'><a rel="index" title="Index"
155 href="genindex.html"><img src='../icons/index.png'
156 border='0' height='32' alt='Index' width='32' /></A></td>
157</tr></table>
158<div class='online-navigation'>
159<b class="navlabel">Previous:</b>
160<a class="sectref" rel="prev" href="node479.html">11.2.10 Common problems and</A>
161<b class="navlabel">Up:</b>
162<a class="sectref" rel="parent" href="internet.html">11. Internet Protocols and</A>
163<b class="navlabel">Next:</b>
164<a class="sectref" rel="next" href="module-urllib.html">11.4 urllib </A>
165</div>
166</div>
167<hr />
168<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
169</DIV>
170<!--End of Navigation Panel-->
171<ADDRESS>
172See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
173</ADDRESS>
174</BODY>
175</HTML>