This file is indexed.

/usr/share/doc/python-werkzeug-doc/html/contrib/wrappers.html is in python-werkzeug-doc 0.9.4+dfsg-1.1ubuntu2.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Extra Wrappers &mdash; Werkzeug 0.9.4 documentation</title>
    
    <link rel="stylesheet" href="../_static/werkzeug.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '0.9.4',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="top" title="Werkzeug 0.9.4 documentation" href="../index.html" />
    <link rel="up" title="Contributed Modules" href="index.html" />
    <link rel="next" title="Iter IO" href="iterio.html" />
    <link rel="prev" title="Cache" href="cache.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="iterio.html" title="Iter IO"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="cache.html" title="Cache"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">Werkzeug 0.9.4 documentation</a> &raquo;</li>
          <li><a href="index.html" accesskey="U">Contributed Modules</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-werkzeug.contrib.wrappers">
<span id="extra-wrappers"></span><h1>Extra Wrappers<a class="headerlink" href="#module-werkzeug.contrib.wrappers" title="Permalink to this headline"></a></h1>
<p>Extra wrappers or mixins contributed by the community.  These wrappers can
be mixed in into request objects to add extra functionality.</p>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">werkzeug.wrappers</span> <span class="kn">import</span> <span class="n">Request</span> <span class="k">as</span> <span class="n">RequestBase</span>
<span class="kn">from</span> <span class="nn">werkzeug.contrib.wrappers</span> <span class="kn">import</span> <span class="n">JSONRequestMixin</span>

<span class="k">class</span> <span class="nc">Request</span><span class="p">(</span><span class="n">RequestBase</span><span class="p">,</span> <span class="n">JSONRequestMixin</span><span class="p">):</span>
    <span class="k">pass</span>
</pre></div>
</div>
<p>Afterwards this request object provides the extra functionality of the
<a class="reference internal" href="#werkzeug.contrib.wrappers.JSONRequestMixin" title="werkzeug.contrib.wrappers.JSONRequestMixin"><tt class="xref py py-class docutils literal"><span class="pre">JSONRequestMixin</span></tt></a>.</p>
<dl class="class">
<dt id="werkzeug.contrib.wrappers.JSONRequestMixin">
<em class="property">class </em><tt class="descclassname">werkzeug.contrib.wrappers.</tt><tt class="descname">JSONRequestMixin</tt><a class="headerlink" href="#werkzeug.contrib.wrappers.JSONRequestMixin" title="Permalink to this definition"></a></dt>
<dd><p>Add json method to a request object.  This will parse the input data
through simplejson if possible.</p>
<p><a class="reference internal" href="../exceptions.html#werkzeug.exceptions.BadRequest" title="werkzeug.exceptions.BadRequest"><tt class="xref py py-exc docutils literal"><span class="pre">BadRequest</span></tt></a> will be raised if the content-type
is not json or if the data itself cannot be parsed as json.</p>
<dl class="attribute">
<dt id="werkzeug.contrib.wrappers.JSONRequestMixin.json">
<tt class="descname">json</tt><a class="headerlink" href="#werkzeug.contrib.wrappers.JSONRequestMixin.json" title="Permalink to this definition"></a></dt>
<dd><p>Get the result of simplejson.loads if possible.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.contrib.wrappers.ProtobufRequestMixin">
<em class="property">class </em><tt class="descclassname">werkzeug.contrib.wrappers.</tt><tt class="descname">ProtobufRequestMixin</tt><a class="headerlink" href="#werkzeug.contrib.wrappers.ProtobufRequestMixin" title="Permalink to this definition"></a></dt>
<dd><p>Add protobuf parsing method to a request object.  This will parse the
input data through <a class="reference external" href="http://code.google.com/p/protobuf/">protobuf</a> if possible.</p>
<p><a class="reference internal" href="../exceptions.html#werkzeug.exceptions.BadRequest" title="werkzeug.exceptions.BadRequest"><tt class="xref py py-exc docutils literal"><span class="pre">BadRequest</span></tt></a> will be raised if the content-type
is not protobuf or if the data itself cannot be parsed property.</p>
<dl class="method">
<dt id="werkzeug.contrib.wrappers.ProtobufRequestMixin.parse_protobuf">
<tt class="descname">parse_protobuf</tt><big>(</big><em>proto_type</em><big>)</big><a class="headerlink" href="#werkzeug.contrib.wrappers.ProtobufRequestMixin.parse_protobuf" title="Permalink to this definition"></a></dt>
<dd><p>Parse the data into an instance of proto_type.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.contrib.wrappers.ProtobufRequestMixin.protobuf_check_initialization">
<tt class="descname">protobuf_check_initialization</tt><em class="property"> = True</em><a class="headerlink" href="#werkzeug.contrib.wrappers.ProtobufRequestMixin.protobuf_check_initialization" title="Permalink to this definition"></a></dt>
<dd><p>by default the <a class="reference internal" href="#werkzeug.contrib.wrappers.ProtobufRequestMixin" title="werkzeug.contrib.wrappers.ProtobufRequestMixin"><tt class="xref py py-class docutils literal"><span class="pre">ProtobufRequestMixin</span></tt></a> will raise a
<a class="reference internal" href="../exceptions.html#werkzeug.exceptions.BadRequest" title="werkzeug.exceptions.BadRequest"><tt class="xref py py-exc docutils literal"><span class="pre">BadRequest</span></tt></a> if the object is not
initialized.  You can bypass that check by setting this
attribute to <cite>False</cite>.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.contrib.wrappers.RoutingArgsRequestMixin">
<em class="property">class </em><tt class="descclassname">werkzeug.contrib.wrappers.</tt><tt class="descname">RoutingArgsRequestMixin</tt><a class="headerlink" href="#werkzeug.contrib.wrappers.RoutingArgsRequestMixin" title="Permalink to this definition"></a></dt>
<dd><p>This request mixin adds support for the wsgiorg routing args
<a class="reference external" href="http://www.wsgi.org/wsgi/Specifications/routing_args">specification</a>.</p>
<dl class="attribute">
<dt id="werkzeug.contrib.wrappers.RoutingArgsRequestMixin.routing_args">
<tt class="descname">routing_args</tt><a class="headerlink" href="#werkzeug.contrib.wrappers.RoutingArgsRequestMixin.routing_args" title="Permalink to this definition"></a></dt>
<dd><p>The positional URL arguments as <cite>tuple</cite>.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.contrib.wrappers.RoutingArgsRequestMixin.routing_vars">
<tt class="descname">routing_vars</tt><a class="headerlink" href="#werkzeug.contrib.wrappers.RoutingArgsRequestMixin.routing_vars" title="Permalink to this definition"></a></dt>
<dd><p>The keyword URL arguments as <cite>dict</cite>.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.contrib.wrappers.ReverseSlashBehaviorRequestMixin">
<em class="property">class </em><tt class="descclassname">werkzeug.contrib.wrappers.</tt><tt class="descname">ReverseSlashBehaviorRequestMixin</tt><a class="headerlink" href="#werkzeug.contrib.wrappers.ReverseSlashBehaviorRequestMixin" title="Permalink to this definition"></a></dt>
<dd><p>This mixin reverses the trailing slash behavior of <a class="reference internal" href="#werkzeug.contrib.wrappers.ReverseSlashBehaviorRequestMixin.script_root" title="werkzeug.contrib.wrappers.ReverseSlashBehaviorRequestMixin.script_root"><tt class="xref py py-attr docutils literal"><span class="pre">script_root</span></tt></a>
and <a class="reference internal" href="#werkzeug.contrib.wrappers.ReverseSlashBehaviorRequestMixin.path" title="werkzeug.contrib.wrappers.ReverseSlashBehaviorRequestMixin.path"><tt class="xref py py-attr docutils literal"><span class="pre">path</span></tt></a>.  This makes it possible to use <tt class="xref py py-func docutils literal"><span class="pre">urljoin()</span></tt>
directly on the paths.</p>
<p>Because it changes the behavior or <tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt> this class has to be
mixed in <em>before</em> the actual request class:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">MyRequest</span><span class="p">(</span><span class="n">ReverseSlashBehaviorRequestMixin</span><span class="p">,</span> <span class="n">Request</span><span class="p">):</span>
    <span class="k">pass</span>
</pre></div>
</div>
<p>This example shows the differences (for an application mounted on
<cite>/application</cite> and the request going to <cite>/application/foo/bar</cite>):</p>
<blockquote>
<div><table border="1" class="docutils">
<colgroup>
<col width="27%" />
<col width="35%" />
<col width="38%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">&nbsp;</th>
<th class="head">normal behavior</th>
<th class="head">reverse behavior</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><cite>script_root</cite></td>
<td><tt class="docutils literal"><span class="pre">/application</span></tt></td>
<td><tt class="docutils literal"><span class="pre">/application/</span></tt></td>
</tr>
<tr class="row-odd"><td><cite>path</cite></td>
<td><tt class="docutils literal"><span class="pre">/foo/bar</span></tt></td>
<td><tt class="docutils literal"><span class="pre">foo/bar</span></tt></td>
</tr>
</tbody>
</table>
</div></blockquote>
<dl class="attribute">
<dt id="werkzeug.contrib.wrappers.ReverseSlashBehaviorRequestMixin.path">
<tt class="descname">path</tt><a class="headerlink" href="#werkzeug.contrib.wrappers.ReverseSlashBehaviorRequestMixin.path" title="Permalink to this definition"></a></dt>
<dd><p>Requested path as unicode.  This works a bit like the regular path
info in the WSGI environment but will not include a leading slash.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.contrib.wrappers.ReverseSlashBehaviorRequestMixin.script_root">
<tt class="descname">script_root</tt><a class="headerlink" href="#werkzeug.contrib.wrappers.ReverseSlashBehaviorRequestMixin.script_root" title="Permalink to this definition"></a></dt>
<dd><p>The root path of the script includling a trailing slash.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.contrib.wrappers.DynamicCharsetRequestMixin">
<em class="property">class </em><tt class="descclassname">werkzeug.contrib.wrappers.</tt><tt class="descname">DynamicCharsetRequestMixin</tt><a class="headerlink" href="#werkzeug.contrib.wrappers.DynamicCharsetRequestMixin" title="Permalink to this definition"></a></dt>
<dd><p>&#8220;If this mixin is mixed into a request class it will provide
a dynamic <cite>charset</cite> attribute.  This means that if the charset is
transmitted in the content type headers it&#8217;s used from there.</p>
<p>Because it changes the behavior or <tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt> this class has
to be mixed in <em>before</em> the actual request class:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">MyRequest</span><span class="p">(</span><span class="n">DynamicCharsetRequestMixin</span><span class="p">,</span> <span class="n">Request</span><span class="p">):</span>
    <span class="k">pass</span>
</pre></div>
</div>
<p>By default the request object assumes that the URL charset is the
same as the data charset.  If the charset varies on each request
based on the transmitted data it&#8217;s not a good idea to let the URLs
change based on that.  Most browsers assume either utf-8 or latin1
for the URLs if they have troubles figuring out.  It&#8217;s strongly
recommended to set the URL charset to utf-8:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">MyRequest</span><span class="p">(</span><span class="n">DynamicCharsetRequestMixin</span><span class="p">,</span> <span class="n">Request</span><span class="p">):</span>
    <span class="n">url_charset</span> <span class="o">=</span> <span class="s">&#39;utf-8&#39;</span>
</pre></div>
</div>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.6.</span></p>
</div>
<dl class="attribute">
<dt id="werkzeug.contrib.wrappers.DynamicCharsetRequestMixin.charset">
<tt class="descname">charset</tt><a class="headerlink" href="#werkzeug.contrib.wrappers.DynamicCharsetRequestMixin.charset" title="Permalink to this definition"></a></dt>
<dd><p>The charset from the content type.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.contrib.wrappers.DynamicCharsetRequestMixin.default_charset">
<tt class="descname">default_charset</tt><em class="property"> = 'latin1'</em><a class="headerlink" href="#werkzeug.contrib.wrappers.DynamicCharsetRequestMixin.default_charset" title="Permalink to this definition"></a></dt>
<dd><p>the default charset that is assumed if the content type header
is missing or does not contain a charset parameter.  The default
is latin1 which is what HTTP specifies as default charset.
You may however want to set this to utf-8 to better support
browsers that do not transmit a charset for incoming data.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.contrib.wrappers.DynamicCharsetRequestMixin.unknown_charset">
<tt class="descname">unknown_charset</tt><big>(</big><em>charset</em><big>)</big><a class="headerlink" href="#werkzeug.contrib.wrappers.DynamicCharsetRequestMixin.unknown_charset" title="Permalink to this definition"></a></dt>
<dd><p>Called if a charset was provided but is not supported by
the Python codecs module.  By default latin1 is assumed then
to not lose any information, you may override this method to
change the behavior.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>charset</strong> &#8211; the charset that was not found.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">the replacement charset.</td>
</tr>
</tbody>
</table>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.contrib.wrappers.DynamicCharsetResponseMixin">
<em class="property">class </em><tt class="descclassname">werkzeug.contrib.wrappers.</tt><tt class="descname">DynamicCharsetResponseMixin</tt><a class="headerlink" href="#werkzeug.contrib.wrappers.DynamicCharsetResponseMixin" title="Permalink to this definition"></a></dt>
<dd><p>If this mixin is mixed into a response class it will provide
a dynamic <cite>charset</cite> attribute.  This means that if the charset is
looked up and stored in the <cite>Content-Type</cite> header and updates
itself automatically.  This also means a small performance hit but
can be useful if you&#8217;re working with different charsets on
responses.</p>
<p>Because the charset attribute is no a property at class-level, the
default value is stored in <cite>default_charset</cite>.</p>
<p>Because it changes the behavior or <tt class="xref py py-class docutils literal"><span class="pre">Response</span></tt> this class has
to be mixed in <em>before</em> the actual response class:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">MyResponse</span><span class="p">(</span><span class="n">DynamicCharsetResponseMixin</span><span class="p">,</span> <span class="n">Response</span><span class="p">):</span>
    <span class="k">pass</span>
</pre></div>
</div>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.6.</span></p>
</div>
<dl class="attribute">
<dt id="werkzeug.contrib.wrappers.DynamicCharsetResponseMixin.charset">
<tt class="descname">charset</tt><a class="headerlink" href="#werkzeug.contrib.wrappers.DynamicCharsetResponseMixin.charset" title="Permalink to this definition"></a></dt>
<dd><p>The charset for the response.  It&#8217;s stored inside the
Content-Type header as a parameter.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.contrib.wrappers.DynamicCharsetResponseMixin.default_charset">
<tt class="descname">default_charset</tt><em class="property"> = 'utf-8'</em><a class="headerlink" href="#werkzeug.contrib.wrappers.DynamicCharsetResponseMixin.default_charset" title="Permalink to this definition"></a></dt>
<dd><p>the default charset.</p>
</dd></dl>

</dd></dl>

</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper"><p class="logo"><a href="../index.html">
  <img class="logo" src="../_static/werkzeug.png" alt="Logo"/>
</a></p><h3>Related Topics</h3>
<ul>
  <li><a href="../index.html">Documentation overview</a><ul>
  <li><a href="index.html">Contributed Modules</a><ul>
      <li>Previous: <a href="cache.html" title="previous chapter">Cache</a></li>
      <li>Next: <a href="iterio.html" title="next chapter">Iter IO</a></li>
  </ul></li>
  </ul></li>
</ul>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/contrib/wrappers.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy; Copyright 2011, The Werkzeug Team.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
    </div>
  </body>
</html>