/usr/share/doc/python-pymongo-doc/html/api/bson/son.html is in python-pymongo-doc 2.6.3-1build1.
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 | <!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>son – Tools for working with SON, an ordered mapping — PyMongo 2.6.3 documentation</title>
<link rel="stylesheet" href="../../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../../',
VERSION: '2.6.3',
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>
<script type="text/javascript" src="../../_static/sidebar.js"></script>
<link rel="top" title="PyMongo 2.6.3 documentation" href="../../index.html" />
<link rel="up" title="bson – BSON (Binary JSON) Encoding and Decoding" href="index.html" />
<link rel="next" title="timestamp – Tools for representing MongoDB internal Timestamps" href="timestamp.html" />
<link rel="prev" title="objectid – Tools for working with MongoDB ObjectIds" href="objectid.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="timestamp.html" title="timestamp – Tools for representing MongoDB internal Timestamps"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="objectid.html" title="objectid – Tools for working with MongoDB ObjectIds"
accesskey="P">previous</a> |</li>
<li><a href="../../index.html">PyMongo 2.6.3 documentation</a> »</li>
<li><a href="../index.html" >API Documentation</a> »</li>
<li><a href="index.html" accesskey="U"><tt class="docutils literal"><span class="pre">bson</span></tt> – BSON (Binary JSON) Encoding and Decoding</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="module-bson.son">
<span id="son-tools-for-working-with-son-an-ordered-mapping"></span><h1><tt class="xref py py-mod docutils literal"><span class="pre">son</span></tt> – Tools for working with SON, an ordered mapping<a class="headerlink" href="#module-bson.son" title="Permalink to this headline">¶</a></h1>
<p>Tools for creating and manipulating SON, the Serialized Ocument Notation.</p>
<p>Regular dictionaries can be used instead of SON objects, but not when the order
of keys is important. A SON object can be used just like a normal Python
dictionary.</p>
<dl class="class">
<dt id="bson.son.SON">
<em class="property">class </em><tt class="descclassname">bson.son.</tt><tt class="descname">SON</tt><big>(</big><em>data=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#bson.son.SON" title="Permalink to this definition">¶</a></dt>
<dd><p>SON data.</p>
<p>A subclass of dict that maintains ordering of keys and provides a
few extra niceties for dealing with SON. SON objects can be
converted to and from BSON.</p>
<p>The mapping from Python types to BSON types is as follows:</p>
<table border="1" class="docutils">
<colgroup>
<col width="52%" />
<col width="19%" />
<col width="28%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Python Type</th>
<th class="head">BSON Type</th>
<th class="head">Supported Direction</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>None</td>
<td>null</td>
<td>both</td>
</tr>
<tr class="row-odd"><td>bool</td>
<td>boolean</td>
<td>both</td>
</tr>
<tr class="row-even"><td>int <a class="footnote-reference" href="#int" id="id1">[1]</a></td>
<td>int32 / int64</td>
<td>py -> bson</td>
</tr>
<tr class="row-odd"><td>long</td>
<td>int64</td>
<td>both</td>
</tr>
<tr class="row-even"><td>float</td>
<td>number (real)</td>
<td>both</td>
</tr>
<tr class="row-odd"><td>string</td>
<td>string</td>
<td>py -> bson</td>
</tr>
<tr class="row-even"><td>unicode</td>
<td>string</td>
<td>both</td>
</tr>
<tr class="row-odd"><td>list</td>
<td>array</td>
<td>both</td>
</tr>
<tr class="row-even"><td>dict / <cite>SON</cite></td>
<td>object</td>
<td>both</td>
</tr>
<tr class="row-odd"><td>datetime.datetime <a class="footnote-reference" href="#dt" id="id2">[2]</a> <a class="footnote-reference" href="#dt2" id="id3">[3]</a></td>
<td>date</td>
<td>both</td>
</tr>
<tr class="row-even"><td>compiled re</td>
<td>regex</td>
<td>both</td>
</tr>
<tr class="row-odd"><td><cite>bson.binary.Binary</cite></td>
<td>binary</td>
<td>both</td>
</tr>
<tr class="row-even"><td><cite>bson.objectid.ObjectId</cite></td>
<td>oid</td>
<td>both</td>
</tr>
<tr class="row-odd"><td><cite>bson.dbref.DBRef</cite></td>
<td>dbref</td>
<td>both</td>
</tr>
<tr class="row-even"><td>None</td>
<td>undefined</td>
<td>bson -> py</td>
</tr>
<tr class="row-odd"><td>unicode</td>
<td>code</td>
<td>bson -> py</td>
</tr>
<tr class="row-even"><td><cite>bson.code.Code</cite></td>
<td>code</td>
<td>py -> bson</td>
</tr>
<tr class="row-odd"><td>unicode</td>
<td>symbol</td>
<td>bson -> py</td>
</tr>
<tr class="row-even"><td>bytes (Python 3) <a class="footnote-reference" href="#bytes" id="id4">[4]</a></td>
<td>binary</td>
<td>both</td>
</tr>
</tbody>
</table>
<p>Note that to save binary data it must be wrapped as an instance of
<cite>bson.binary.Binary</cite>. Otherwise it will be saved as a BSON string
and retrieved as unicode.</p>
<table class="docutils footnote" frame="void" id="int" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id1">[1]</a></td><td>A Python int will be saved as a BSON int32 or BSON int64 depending
on its size. A BSON int32 will always decode to a Python int. In Python 2.x
a BSON int64 will always decode to a Python long. In Python 3.x a BSON
int64 will decode to a Python int since there is no longer a long type.</td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="dt" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id2">[2]</a></td><td>datetime.datetime instances will be rounded to the nearest
millisecond when saved</td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="dt2" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id3">[3]</a></td><td>all datetime.datetime instances are treated as <em>naive</em>. clients
should always use UTC.</td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="bytes" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id4">[4]</a></td><td>The bytes type from Python 3.x is encoded as BSON binary with
subtype 0. In Python 3.x it will be decoded back to bytes. In Python 2.x
it will be decoded to an instance of <a class="reference internal" href="binary.html#bson.binary.Binary" title="bson.binary.Binary"><tt class="xref py py-class docutils literal"><span class="pre">Binary</span></tt></a> with
subtype 0.</td></tr>
</tbody>
</table>
<dl class="method">
<dt id="bson.son.SON.to_dict">
<tt class="descname">to_dict</tt><big>(</big><big>)</big><a class="headerlink" href="#bson.son.SON.to_dict" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a SON document to a normal Python dictionary instance.</p>
<p>This is trickier than just <em>dict(...)</em> because it needs to be
recursive.</p>
</dd></dl>
</dd></dl>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="objectid.html"
title="previous chapter"><tt class="docutils literal"><span class="pre">objectid</span></tt> – Tools for working with MongoDB ObjectIds</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="timestamp.html"
title="next chapter"><tt class="docutils literal"><span class="pre">timestamp</span></tt> – Tools for representing MongoDB internal Timestamps</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../../_sources/api/bson/son.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="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="timestamp.html" title="timestamp – Tools for representing MongoDB internal Timestamps"
>next</a> |</li>
<li class="right" >
<a href="objectid.html" title="objectid – Tools for working with MongoDB ObjectIds"
>previous</a> |</li>
<li><a href="../../index.html">PyMongo 2.6.3 documentation</a> »</li>
<li><a href="../index.html" >API Documentation</a> »</li>
<li><a href="index.html" ><tt class="docutils literal"><span class="pre">bson</span></tt> – BSON (Binary JSON) Encoding and Decoding</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2008 - 2012, 10gen, Inc..
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.
</div>
</body>
</html>
|