~dkuhlman/python-training-materials/Materials

« back to all changes in this revision

Viewing changes to python-2.7.11-docs-html/library/cgitb.html

  • Committer: Dave Kuhlman
  • Date: 2017-04-15 16:24:56 UTC
  • Revision ID: dkuhlman@davekuhlman.org-20170415162456-iav9vozzg4iwqwv3
Updated docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
 
 
4
 
 
5
 
<html xmlns="http://www.w3.org/1999/xhtml">
6
 
  <head>
7
 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
8
 
    
9
 
    <title>20.3. cgitb — Traceback manager for CGI scripts &mdash; Python 2.7.11 documentation</title>
10
 
    
11
 
    <link rel="stylesheet" href="../_static/classic.css" type="text/css" />
12
 
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
13
 
    
14
 
    <script type="text/javascript">
15
 
      var DOCUMENTATION_OPTIONS = {
16
 
        URL_ROOT:    '../',
17
 
        VERSION:     '2.7.11',
18
 
        COLLAPSE_INDEX: false,
19
 
        FILE_SUFFIX: '.html',
20
 
        HAS_SOURCE:  true
21
 
      };
22
 
    </script>
23
 
    <script type="text/javascript" src="../_static/jquery.js"></script>
24
 
    <script type="text/javascript" src="../_static/underscore.js"></script>
25
 
    <script type="text/javascript" src="../_static/doctools.js"></script>
26
 
    <script type="text/javascript" src="../_static/sidebar.js"></script>
27
 
    <link rel="search" type="application/opensearchdescription+xml"
28
 
          title="Search within Python 2.7.11 documentation"
29
 
          href="../_static/opensearch.xml"/>
30
 
    <link rel="author" title="About these documents" href="../about.html" />
31
 
    <link rel="copyright" title="Copyright" href="../copyright.html" />
32
 
    <link rel="top" title="Python 2.7.11 documentation" href="../contents.html" />
33
 
    <link rel="up" title="20. Internet Protocols and Support" href="internet.html" />
34
 
    <link rel="next" title="20.4. wsgiref — WSGI Utilities and Reference Implementation" href="wsgiref.html" />
35
 
    <link rel="prev" title="20.2. cgi — Common Gateway Interface support" href="cgi.html" />
36
 
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
37
 
    <script type="text/javascript" src="../_static/copybutton.js"></script>
38
 
    <script type="text/javascript" src="../_static/version_switch.js"></script>
39
 
 
40
 
    
41
 
 
42
 
  </head>
43
 
  <body role="document">  
44
 
    <div class="related" role="navigation" aria-label="related navigation">
45
 
      <h3>Navigation</h3>
46
 
      <ul>
47
 
        <li class="right" style="margin-right: 10px">
48
 
          <a href="../genindex.html" title="General Index"
49
 
             accesskey="I">index</a></li>
50
 
        <li class="right" >
51
 
          <a href="../py-modindex.html" title="Python Module Index"
52
 
             >modules</a> |</li>
53
 
        <li class="right" >
54
 
          <a href="wsgiref.html" title="20.4. wsgiref — WSGI Utilities and Reference Implementation"
55
 
             accesskey="N">next</a> |</li>
56
 
        <li class="right" >
57
 
          <a href="cgi.html" title="20.2. cgi — Common Gateway Interface support"
58
 
             accesskey="P">previous</a> |</li>
59
 
        <li><img src="../_static/py.png" alt=""
60
 
                 style="vertical-align: middle; margin-top: -1px"/></li>
61
 
        <li><a href="https://www.python.org/">Python</a> &raquo;</li>
62
 
        <li>
63
 
          <span class="version_switcher_placeholder">2.7.11</span>
64
 
          <a href="../index.html">Documentation</a> &raquo;
65
 
        </li>
66
 
 
67
 
          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &raquo;</li>
68
 
          <li class="nav-item nav-item-2"><a href="internet.html" accesskey="U">20. Internet Protocols and Support</a> &raquo;</li> 
69
 
      </ul>
70
 
    </div>    
71
 
 
72
 
    <div class="document">
73
 
      <div class="documentwrapper">
74
 
        <div class="bodywrapper">
75
 
          <div class="body" role="main">
76
 
            
77
 
  <div class="section" id="module-cgitb">
78
 
<span id="cgitb-traceback-manager-for-cgi-scripts"></span><h1>20.3. <a class="reference internal" href="#module-cgitb" title="cgitb: Configurable traceback handler for CGI scripts."><code class="xref py py-mod docutils literal"><span class="pre">cgitb</span></code></a> &#8212; Traceback manager for CGI scripts<a class="headerlink" href="#module-cgitb" title="Permalink to this headline">¶</a></h1>
79
 
<div class="versionadded">
80
 
<p><span class="versionmodified">New in version 2.2.</span></p>
81
 
</div>
82
 
<p id="index-0">The <a class="reference internal" href="#module-cgitb" title="cgitb: Configurable traceback handler for CGI scripts."><code class="xref py py-mod docutils literal"><span class="pre">cgitb</span></code></a> module provides a special exception handler for Python scripts.
83
 
(Its name is a bit misleading.  It was originally designed to display extensive
84
 
traceback information in HTML for CGI scripts.  It was later generalized to also
85
 
display this information in plain text.)  After this module is activated, if an
86
 
uncaught exception occurs, a detailed, formatted report will be displayed.  The
87
 
report includes a traceback showing excerpts of the source code for each level,
88
 
as well as the values of the arguments and local variables to currently running
89
 
functions, to help you debug the problem.  Optionally, you can save this
90
 
information to a file instead of sending it to the browser.</p>
91
 
<p>To enable this feature, simply add this to the top of your CGI script:</p>
92
 
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">cgitb</span>
93
 
<span class="n">cgitb</span><span class="o">.</span><span class="n">enable</span><span class="p">()</span>
94
 
</pre></div>
95
 
</div>
96
 
<p>The options to the <a class="reference internal" href="#cgitb.enable" title="cgitb.enable"><code class="xref py py-func docutils literal"><span class="pre">enable()</span></code></a> function control whether the report is
97
 
displayed in the browser and whether the report is logged to a file for later
98
 
analysis.</p>
99
 
<dl class="function">
100
 
<dt id="cgitb.enable">
101
 
<code class="descclassname">cgitb.</code><code class="descname">enable</code><span class="sig-paren">(</span><span class="optional">[</span><em>display</em><span class="optional">[</span>, <em>logdir</em><span class="optional">[</span>, <em>context</em><span class="optional">[</span>, <em>format</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#cgitb.enable" title="Permalink to this definition">¶</a></dt>
102
 
<dd><p id="index-1">This function causes the <a class="reference internal" href="#module-cgitb" title="cgitb: Configurable traceback handler for CGI scripts."><code class="xref py py-mod docutils literal"><span class="pre">cgitb</span></code></a> module to take over the interpreter&#8217;s
103
 
default handling for exceptions by setting the value of <a class="reference internal" href="sys.html#sys.excepthook" title="sys.excepthook"><code class="xref py py-attr docutils literal"><span class="pre">sys.excepthook</span></code></a>.</p>
104
 
<p>The optional argument <em>display</em> defaults to <code class="docutils literal"><span class="pre">1</span></code> and can be set to <code class="docutils literal"><span class="pre">0</span></code> to
105
 
suppress sending the traceback to the browser. If the argument <em>logdir</em> is
106
 
present, the traceback reports are written to files.  The value of <em>logdir</em>
107
 
should be a directory where these files will be placed. The optional argument
108
 
<em>context</em> is the number of lines of context to display around the current line
109
 
of source code in the traceback; this defaults to <code class="docutils literal"><span class="pre">5</span></code>. If the optional
110
 
argument <em>format</em> is <code class="docutils literal"><span class="pre">&quot;html&quot;</span></code>, the output is formatted as HTML.  Any other
111
 
value forces plain text output.  The default value is <code class="docutils literal"><span class="pre">&quot;html&quot;</span></code>.</p>
112
 
</dd></dl>
113
 
 
114
 
<dl class="function">
115
 
<dt id="cgitb.handler">
116
 
<code class="descclassname">cgitb.</code><code class="descname">handler</code><span class="sig-paren">(</span><span class="optional">[</span><em>info</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#cgitb.handler" title="Permalink to this definition">¶</a></dt>
117
 
<dd><p>This function handles an exception using the default settings (that is, show a
118
 
report in the browser, but don&#8217;t log to a file). This can be used when you&#8217;ve
119
 
caught an exception and want to report it using <a class="reference internal" href="#module-cgitb" title="cgitb: Configurable traceback handler for CGI scripts."><code class="xref py py-mod docutils literal"><span class="pre">cgitb</span></code></a>.  The optional
120
 
<em>info</em> argument should be a 3-tuple containing an exception type, exception
121
 
value, and traceback object, exactly like the tuple returned by
122
 
<a class="reference internal" href="sys.html#sys.exc_info" title="sys.exc_info"><code class="xref py py-func docutils literal"><span class="pre">sys.exc_info()</span></code></a>.  If the <em>info</em> argument is not supplied, the current
123
 
exception is obtained from <a class="reference internal" href="sys.html#sys.exc_info" title="sys.exc_info"><code class="xref py py-func docutils literal"><span class="pre">sys.exc_info()</span></code></a>.</p>
124
 
</dd></dl>
125
 
 
126
 
</div>
127
 
 
128
 
 
129
 
          </div>
130
 
        </div>
131
 
      </div>
132
 
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
133
 
        <div class="sphinxsidebarwrapper">
134
 
  <h4>Previous topic</h4>
135
 
  <p class="topless"><a href="cgi.html"
136
 
                        title="previous chapter">20.2. <code class="docutils literal"><span class="pre">cgi</span></code> &#8212; Common Gateway Interface support</a></p>
137
 
  <h4>Next topic</h4>
138
 
  <p class="topless"><a href="wsgiref.html"
139
 
                        title="next chapter">20.4. <code class="docutils literal"><span class="pre">wsgiref</span></code> &#8212; WSGI Utilities and Reference Implementation</a></p>
140
 
<h3>This Page</h3>
141
 
<ul class="this-page-menu">
142
 
  <li><a href="../bugs.html">Report a Bug</a></li>
143
 
  <li><a href="../_sources/library/cgitb.txt"
144
 
         rel="nofollow">Show Source</a></li>
145
 
</ul>
146
 
 
147
 
<div id="searchbox" style="display: none" role="search">
148
 
  <h3>Quick search</h3>
149
 
    <form class="search" action="../search.html" method="get">
150
 
      <input type="text" name="q" />
151
 
      <input type="submit" value="Go" />
152
 
      <input type="hidden" name="check_keywords" value="yes" />
153
 
      <input type="hidden" name="area" value="default" />
154
 
    </form>
155
 
    <p class="searchtip" style="font-size: 90%">
156
 
    Enter search terms or a module, class or function name.
157
 
    </p>
158
 
</div>
159
 
<script type="text/javascript">$('#searchbox').show(0);</script>
160
 
        </div>
161
 
      </div>
162
 
      <div class="clearer"></div>
163
 
    </div>  
164
 
    <div class="related" role="navigation" aria-label="related navigation">
165
 
      <h3>Navigation</h3>
166
 
      <ul>
167
 
        <li class="right" style="margin-right: 10px">
168
 
          <a href="../genindex.html" title="General Index"
169
 
             >index</a></li>
170
 
        <li class="right" >
171
 
          <a href="../py-modindex.html" title="Python Module Index"
172
 
             >modules</a> |</li>
173
 
        <li class="right" >
174
 
          <a href="wsgiref.html" title="20.4. wsgiref — WSGI Utilities and Reference Implementation"
175
 
             >next</a> |</li>
176
 
        <li class="right" >
177
 
          <a href="cgi.html" title="20.2. cgi — Common Gateway Interface support"
178
 
             >previous</a> |</li>
179
 
        <li><img src="../_static/py.png" alt=""
180
 
                 style="vertical-align: middle; margin-top: -1px"/></li>
181
 
        <li><a href="https://www.python.org/">Python</a> &raquo;</li>
182
 
        <li>
183
 
          <span class="version_switcher_placeholder">2.7.11</span>
184
 
          <a href="../index.html">Documentation</a> &raquo;
185
 
        </li>
186
 
 
187
 
          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &raquo;</li>
188
 
          <li class="nav-item nav-item-2"><a href="internet.html" >20. Internet Protocols and Support</a> &raquo;</li> 
189
 
      </ul>
190
 
    </div>  
191
 
    <div class="footer">
192
 
    &copy; <a href="../copyright.html">Copyright</a> 1990-2016, Python Software Foundation.
193
 
    <br />
194
 
    The Python Software Foundation is a non-profit corporation.
195
 
    <a href="https://www.python.org/psf/donations/">Please donate.</a>
196
 
    <br />
197
 
    Last updated on Jan 23, 2016.
198
 
    <a href="../bugs.html">Found a bug</a>?
199
 
    <br />
200
 
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.3.3.
201
 
    </div>
202
 
 
203
 
  </body>
204
 
</html>
 
 
b'\\ No newline at end of file'