/usr/share/doc/python-webob-doc/api/cookies.html is in python-webob-doc 1:1.6.2-2.
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 | <!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>webob.cookies – Cookies — WebOb 1.6.2 documentation</title>
<link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '1.6.2',
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="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="top" title="WebOb 1.6.2 documentation" href="../index.html" />
<link rel="next" title="webob.dec – WSGIfy decorator" href="dec.html" />
<link rel="prev" title="webob.client – Send WSGI requests over HTTP" href="client.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head>
<body role="document">
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="webob-cookies-cookies">
<h1><code class="xref py py-mod docutils literal"><span class="pre">webob.cookies</span></code> – Cookies<a class="headerlink" href="#webob-cookies-cookies" title="Permalink to this headline">¶</a></h1>
<div class="section" id="cookies">
<h2>Cookies<a class="headerlink" href="#cookies" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="webob.cookies.CookieProfile">
<em class="property">class </em><code class="descclassname">webob.cookies.</code><code class="descname">CookieProfile</code><span class="sig-paren">(</span><em>cookie_name</em>, <em>secure=False</em>, <em>max_age=None</em>, <em>httponly=None</em>, <em>path='/'</em>, <em>domains=None</em>, <em>serializer=None</em><span class="sig-paren">)</span><a class="headerlink" href="#webob.cookies.CookieProfile" title="Permalink to this definition">¶</a></dt>
<dd><p>A helper class that helps bring some sanity to the insanity that is cookie
handling.</p>
<p>The helper is capable of generating multiple cookies if necessary to
support subdomains and parent domains.</p>
<dl class="docutils">
<dt><code class="docutils literal"><span class="pre">cookie_name</span></code></dt>
<dd>The name of the cookie used for sessioning. Default: <code class="docutils literal"><span class="pre">'session'</span></code>.</dd>
<dt><code class="docutils literal"><span class="pre">max_age</span></code></dt>
<dd>The maximum age of the cookie used for sessioning (in seconds).
Default: <code class="docutils literal"><span class="pre">None</span></code> (browser scope).</dd>
<dt><code class="docutils literal"><span class="pre">secure</span></code></dt>
<dd>The ‘secure’ flag of the session cookie. Default: <code class="docutils literal"><span class="pre">False</span></code>.</dd>
<dt><code class="docutils literal"><span class="pre">httponly</span></code></dt>
<dd>Hide the cookie from Javascript by setting the ‘HttpOnly’ flag of the
session cookie. Default: <code class="docutils literal"><span class="pre">False</span></code>.</dd>
<dt><code class="docutils literal"><span class="pre">path</span></code></dt>
<dd>The path used for the session cookie. Default: <code class="docutils literal"><span class="pre">'/'</span></code>.</dd>
<dt><code class="docutils literal"><span class="pre">domains</span></code></dt>
<dd>The domain(s) used for the session cookie. Default: <code class="docutils literal"><span class="pre">None</span></code> (no domain).
Can be passed an iterable containing multiple domains, this will set
multiple cookies one for each domain.</dd>
<dt><code class="docutils literal"><span class="pre">serializer</span></code></dt>
<dd>An object with two methods: <code class="docutils literal"><span class="pre">loads</span></code> and <code class="docutils literal"><span class="pre">dumps</span></code>. The <code class="docutils literal"><span class="pre">loads</span></code> method
should accept a bytestring and return a Python object. The <code class="docutils literal"><span class="pre">dumps</span></code>
method should accept a Python object and return bytes. A <code class="docutils literal"><span class="pre">ValueError</span></code>
should be raised for malformed inputs. Default: <code class="docutils literal"><span class="pre">None</span></code>, which will use
a derivation of <a class="reference external" href="/usr/share/doc/python3-doc/html/library/json.html#json.dumps" title="(in Python v3.5)"><code class="xref py py-func docutils literal"><span class="pre">json.dumps()</span></code></a> and <a class="reference external" href="/usr/share/doc/python3-doc/html/library/json.html#json.loads" title="(in Python v3.5)"><code class="xref py py-func docutils literal"><span class="pre">json.loads()</span></code></a>.</dd>
</dl>
<dl class="method">
<dt id="webob.cookies.CookieProfile.bind">
<code class="descname">bind</code><span class="sig-paren">(</span><em>request</em><span class="sig-paren">)</span><a class="headerlink" href="#webob.cookies.CookieProfile.bind" title="Permalink to this definition">¶</a></dt>
<dd><p>Bind a request to a copy of this instance and return it</p>
</dd></dl>
<dl class="method">
<dt id="webob.cookies.CookieProfile.get_headers">
<code class="descname">get_headers</code><span class="sig-paren">(</span><em>value</em>, <em>domains=<object object></em>, <em>max_age=<object object></em>, <em>path=<object object></em>, <em>secure=<object object></em>, <em>httponly=<object object></em><span class="sig-paren">)</span><a class="headerlink" href="#webob.cookies.CookieProfile.get_headers" title="Permalink to this definition">¶</a></dt>
<dd><p>Retrieve raw headers for setting cookies.</p>
<p>Returns a list of headers that should be set for the cookies to
be correctly tracked.</p>
</dd></dl>
<dl class="method">
<dt id="webob.cookies.CookieProfile.get_value">
<code class="descname">get_value</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#webob.cookies.CookieProfile.get_value" title="Permalink to this definition">¶</a></dt>
<dd><p>Looks for a cookie by name in the currently bound request, and
returns its value. If the cookie profile is not bound to a request,
this method will raise a <a class="reference external" href="/usr/share/doc/python3-doc/html/library/exceptions.html#ValueError" title="(in Python v3.5)"><code class="xref py py-exc docutils literal"><span class="pre">ValueError</span></code></a>.</p>
<p>Looks for the cookie in the cookies jar, and if it can find it it will
attempt to deserialize it. Returns <code class="docutils literal"><span class="pre">None</span></code> if there is no cookie or
if the value in the cookie cannot be successfully deserialized.</p>
</dd></dl>
<dl class="method">
<dt id="webob.cookies.CookieProfile.set_cookies">
<code class="descname">set_cookies</code><span class="sig-paren">(</span><em>response</em>, <em>value</em>, <em>domains=<object object></em>, <em>max_age=<object object></em>, <em>path=<object object></em>, <em>secure=<object object></em>, <em>httponly=<object object></em><span class="sig-paren">)</span><a class="headerlink" href="#webob.cookies.CookieProfile.set_cookies" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the cookies on a response.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="webob.cookies.SignedCookieProfile">
<em class="property">class </em><code class="descclassname">webob.cookies.</code><code class="descname">SignedCookieProfile</code><span class="sig-paren">(</span><em>secret</em>, <em>salt</em>, <em>cookie_name</em>, <em>secure=False</em>, <em>max_age=None</em>, <em>httponly=False</em>, <em>path='/'</em>, <em>domains=None</em>, <em>hashalg='sha512'</em>, <em>serializer=None</em><span class="sig-paren">)</span><a class="headerlink" href="#webob.cookies.SignedCookieProfile" title="Permalink to this definition">¶</a></dt>
<dd><p>A helper for generating cookies that are signed to prevent tampering.</p>
<p>By default this will create a single cookie, given a value it will
serialize it, then use HMAC to cryptographically sign the data. Finally
the result is base64-encoded for transport. This way a remote user can
not tamper with the value without uncovering the secret/salt used.</p>
<dl class="docutils">
<dt><code class="docutils literal"><span class="pre">secret</span></code></dt>
<dd>A string which is used to sign the cookie. The secret should be at
least as long as the block size of the selected hash algorithm. For
<code class="docutils literal"><span class="pre">sha512</span></code> this would mean a 128 bit (64 character) secret.</dd>
<dt><code class="docutils literal"><span class="pre">salt</span></code></dt>
<dd>A namespace to avoid collisions between different uses of a shared
secret.</dd>
<dt><code class="docutils literal"><span class="pre">hashalg</span></code></dt>
<dd>The HMAC digest algorithm to use for signing. The algorithm must be
supported by the <a class="reference external" href="/usr/share/doc/python3-doc/html/library/hashlib.html#module-hashlib" title="(in Python v3.5)"><code class="xref py py-mod docutils literal"><span class="pre">hashlib</span></code></a> library. Default: <code class="docutils literal"><span class="pre">'sha512'</span></code>.</dd>
<dt><code class="docutils literal"><span class="pre">cookie_name</span></code></dt>
<dd>The name of the cookie used for sessioning. Default: <code class="docutils literal"><span class="pre">'session'</span></code>.</dd>
<dt><code class="docutils literal"><span class="pre">max_age</span></code></dt>
<dd>The maximum age of the cookie used for sessioning (in seconds).
Default: <code class="docutils literal"><span class="pre">None</span></code> (browser scope).</dd>
<dt><code class="docutils literal"><span class="pre">secure</span></code></dt>
<dd>The ‘secure’ flag of the session cookie. Default: <code class="docutils literal"><span class="pre">False</span></code>.</dd>
<dt><code class="docutils literal"><span class="pre">httponly</span></code></dt>
<dd>Hide the cookie from Javascript by setting the ‘HttpOnly’ flag of the
session cookie. Default: <code class="docutils literal"><span class="pre">False</span></code>.</dd>
<dt><code class="docutils literal"><span class="pre">path</span></code></dt>
<dd>The path used for the session cookie. Default: <code class="docutils literal"><span class="pre">'/'</span></code>.</dd>
<dt><code class="docutils literal"><span class="pre">domains</span></code></dt>
<dd>The domain(s) used for the session cookie. Default: <code class="docutils literal"><span class="pre">None</span></code> (no domain).
Can be passed an iterable containing multiple domains, this will set
multiple cookies one for each domain.</dd>
<dt><code class="docutils literal"><span class="pre">serializer</span></code></dt>
<dd>An object with two methods: <cite>loads`</cite> and <code class="docutils literal"><span class="pre">dumps</span></code>. The <code class="docutils literal"><span class="pre">loads</span></code> method
should accept bytes and return a Python object. The <code class="docutils literal"><span class="pre">dumps</span></code> method
should accept a Python object and return bytes. A <code class="docutils literal"><span class="pre">ValueError</span></code> should
be raised for malformed inputs. Default: <code class="docutils literal"><span class="pre">None`,</span> <span class="pre">which</span> <span class="pre">will</span> <span class="pre">use</span> <span class="pre">a</span>
<span class="pre">derivation</span> <span class="pre">of</span> <span class="pre">:func:`json.dumps`</span> <span class="pre">and</span> <span class="pre">``json.loads</span></code>.</dd>
</dl>
<dl class="method">
<dt id="webob.cookies.SignedCookieProfile.bind">
<code class="descname">bind</code><span class="sig-paren">(</span><em>request</em><span class="sig-paren">)</span><a class="headerlink" href="#webob.cookies.SignedCookieProfile.bind" title="Permalink to this definition">¶</a></dt>
<dd><p>Bind a request to a copy of this instance and return it</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="webob.cookies.SignedSerializer">
<em class="property">class </em><code class="descclassname">webob.cookies.</code><code class="descname">SignedSerializer</code><span class="sig-paren">(</span><em>secret</em>, <em>salt</em>, <em>hashalg='sha512'</em>, <em>serializer=None</em><span class="sig-paren">)</span><a class="headerlink" href="#webob.cookies.SignedSerializer" title="Permalink to this definition">¶</a></dt>
<dd><p>A helper to cryptographically sign arbitrary content using HMAC.</p>
<p>The serializer accepts arbitrary functions for performing the actual
serialization and deserialization.</p>
<dl class="docutils">
<dt><code class="docutils literal"><span class="pre">secret</span></code></dt>
<dd>A string which is used to sign the cookie. The secret should be at
least as long as the block size of the selected hash algorithm. For
<code class="docutils literal"><span class="pre">sha512</span></code> this would mean a 128 bit (64 character) secret.</dd>
<dt><code class="docutils literal"><span class="pre">salt</span></code></dt>
<dd>A namespace to avoid collisions between different uses of a shared
secret.</dd>
<dt><code class="docutils literal"><span class="pre">hashalg</span></code></dt>
<dd>The HMAC digest algorithm to use for signing. The algorithm must be
supported by the <a class="reference external" href="/usr/share/doc/python3-doc/html/library/hashlib.html#module-hashlib" title="(in Python v3.5)"><code class="xref py py-mod docutils literal"><span class="pre">hashlib</span></code></a> library. Default: <code class="docutils literal"><span class="pre">'sha512'</span></code>.</dd>
<dt><code class="docutils literal"><span class="pre">serializer</span></code></dt>
<dd>An object with two methods: <cite>loads`</cite> and <code class="docutils literal"><span class="pre">dumps</span></code>. The <code class="docutils literal"><span class="pre">loads</span></code> method
should accept bytes and return a Python object. The <code class="docutils literal"><span class="pre">dumps</span></code> method
should accept a Python object and return bytes. A <code class="docutils literal"><span class="pre">ValueError</span></code> should
be raised for malformed inputs. Default: <code class="docutils literal"><span class="pre">None`,</span> <span class="pre">which</span> <span class="pre">will</span> <span class="pre">use</span> <span class="pre">a</span>
<span class="pre">derivation</span> <span class="pre">of</span> <span class="pre">:func:`json.dumps`</span> <span class="pre">and</span> <span class="pre">``json.loads</span></code>.</dd>
</dl>
<dl class="method">
<dt id="webob.cookies.SignedSerializer.dumps">
<code class="descname">dumps</code><span class="sig-paren">(</span><em>appstruct</em><span class="sig-paren">)</span><a class="headerlink" href="#webob.cookies.SignedSerializer.dumps" title="Permalink to this definition">¶</a></dt>
<dd><p>Given an <code class="docutils literal"><span class="pre">appstruct</span></code>, serialize and sign the data.</p>
<p>Returns a bytestring.</p>
</dd></dl>
<dl class="method">
<dt id="webob.cookies.SignedSerializer.loads">
<code class="descname">loads</code><span class="sig-paren">(</span><em>bstruct</em><span class="sig-paren">)</span><a class="headerlink" href="#webob.cookies.SignedSerializer.loads" title="Permalink to this definition">¶</a></dt>
<dd><p>Given a <code class="docutils literal"><span class="pre">bstruct</span></code> (a bytestring), verify the signature and then
deserialize and return the deserialized value.</p>
<p>A <code class="docutils literal"><span class="pre">ValueError</span></code> will be raised if the signature fails to validate.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="webob.cookies.JSONSerializer">
<em class="property">class </em><code class="descclassname">webob.cookies.</code><code class="descname">JSONSerializer</code><a class="headerlink" href="#webob.cookies.JSONSerializer" title="Permalink to this definition">¶</a></dt>
<dd><p>A serializer which uses <cite>json.dumps`</cite> and <code class="docutils literal"><span class="pre">json.loads</span></code></p>
</dd></dl>
<dl class="function">
<dt id="webob.cookies.make_cookie">
<code class="descclassname">webob.cookies.</code><code class="descname">make_cookie</code><span class="sig-paren">(</span><em>name</em>, <em>value</em>, <em>max_age=None</em>, <em>path='/'</em>, <em>domain=None</em>, <em>secure=False</em>, <em>httponly=False</em>, <em>comment=None</em><span class="sig-paren">)</span><a class="headerlink" href="#webob.cookies.make_cookie" title="Permalink to this definition">¶</a></dt>
<dd><p>Generate a cookie value. If <code class="docutils literal"><span class="pre">value</span></code> is None, generate a cookie value
with an expiration date in the past</p>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#"><code class="docutils literal"><span class="pre">webob.cookies</span></code> – Cookies</a><ul>
<li><a class="reference internal" href="#cookies">Cookies</a></li>
</ul>
</li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="../index.html">Documentation overview</a><ul>
<li>Previous: <a href="client.html" title="previous chapter"><code class="docutils literal"><span class="pre">webob.client</span></code> – Send WSGI requests over HTTP</a></li>
<li>Next: <a href="dec.html" title="next chapter"><code class="docutils literal"><span class="pre">webob.dec</span></code> – WSGIfy decorator</a></li>
</ul></li>
</ul>
</div>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/api/cookies.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<div><input type="text" name="q" /></div>
<div><input type="submit" value="Go" /></div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
©2017, Ian Bicking and contributors.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 1.4.9</a>
& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.8</a>
|
<a href="../_sources/api/cookies.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>
|