This file is indexed.

/usr/share/doc/python-django-mptt/html/mptt.managers.html is in python-django-mptt 0.6.0-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>mptt.managers &mdash; django-mptt 0.6.0 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:     '0.6.0',
        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="django-mptt 0.6.0 documentation" href="index.html" />
    <link rel="up" title="mptt" href="mptt.html" />
    <link rel="next" title="mptt.models" href="mptt.models.html" />
    <link rel="prev" title="mptt.forms" href="mptt.forms.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="mptt.models.html" title="mptt.models"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="mptt.forms.html" title="mptt.forms"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">django-mptt 0.6.0 documentation</a> &raquo;</li>
          <li><a href="autogenerated.html" >Autogenerated documentation</a> &raquo;</li>
          <li><a href="mptt.html" accesskey="U"><tt class="docutils literal docutils literal docutils literal docutils literal docutils literal docutils literal docutils literal docutils literal"><span class="pre">mptt</span></tt></a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-mptt.managers">
<span id="mptt-managers"></span><h1><tt class="docutils literal"><span class="pre">mptt.managers</span></tt><a class="headerlink" href="#module-mptt.managers" title="Permalink to this headline"></a></h1>
<p>A custom manager for working with trees of objects.</p>
<dl class="class">
<dt id="mptt.managers.TreeManager">
<em class="property">class </em><tt class="descclassname">mptt.managers.</tt><tt class="descname">TreeManager</tt><a class="headerlink" href="#mptt.managers.TreeManager" title="Permalink to this definition"></a></dt>
<dd><p>A manager for working with trees of objects.</p>
<dl class="method">
<dt id="mptt.managers.TreeManager.add_related_count">
<tt class="descname">add_related_count</tt><big>(</big><em>queryset</em>, <em>rel_model</em>, <em>rel_field</em>, <em>count_attr</em>, <em>cumulative=False</em><big>)</big><a class="headerlink" href="#mptt.managers.TreeManager.add_related_count" title="Permalink to this definition"></a></dt>
<dd><p>Adds a related item count to a given <tt class="docutils literal"><span class="pre">QuerySet</span></tt> using its
<tt class="docutils literal"><span class="pre">extra</span></tt> method, for a <tt class="docutils literal"><span class="pre">Model</span></tt> class which has a relation to
this <tt class="docutils literal"><span class="pre">Manager</span></tt>&#8216;s <tt class="docutils literal"><span class="pre">Model</span></tt> class.</p>
<p>Arguments:</p>
<dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">rel_model</span></tt></dt>
<dd>A <tt class="docutils literal"><span class="pre">Model</span></tt> class which has a relation to this <cite>Manager`</cite>&#8216;s
<tt class="docutils literal"><span class="pre">Model</span></tt> class.</dd>
<dt><tt class="docutils literal"><span class="pre">rel_field</span></tt></dt>
<dd>The name of the field in <tt class="docutils literal"><span class="pre">rel_model</span></tt> which holds the
relation.</dd>
<dt><tt class="docutils literal"><span class="pre">count_attr</span></tt></dt>
<dd>The name of an attribute which should be added to each item in
this <tt class="docutils literal"><span class="pre">QuerySet</span></tt>, containing a count of how many instances
of <tt class="docutils literal"><span class="pre">rel_model</span></tt> are related to it through <tt class="docutils literal"><span class="pre">rel_field</span></tt>.</dd>
<dt><tt class="docutils literal"><span class="pre">cumulative</span></tt></dt>
<dd>If <tt class="docutils literal"><span class="pre">True</span></tt>, the count will be for each item and all of its
descendants, otherwise it will be for each item itself.</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="mptt.managers.TreeManager.delay_mptt_updates">
<tt class="descname">delay_mptt_updates</tt><big>(</big><em>*args</em>, <em>**kwds</em><big>)</big><a class="headerlink" href="#mptt.managers.TreeManager.delay_mptt_updates" title="Permalink to this definition"></a></dt>
<dd><p>Context manager. Delays mptt updates until the end of a block of bulk processing.</p>
<p>NOTE that this context manager causes inconsistencies! MPTT model methods are
not guaranteed to return the correct results until the end of the context block.</p>
<dl class="docutils">
<dt>When to use this method:</dt>
<dd><p class="first">If used correctly, this method can be used to speed up bulk updates.
This is best for updates in a localised area of the db table, especially if all
the updates happen in a single tree and the rest of the forest is left untouched.
No subsequent rebuild is necessary.</p>
<p>delay_mptt_updates does a partial rebuild of the modified trees (not the whole table).
If used indiscriminately, this can actually be much slower than just letting the updates
occur when they&#8217;re required.</p>
<p>The worst case occurs when every tree in the table is modified just once.
That results in a full rebuild of the table, which can be <em>very</em> slow.</p>
<p class="last">If your updates will modify most of the trees in the table (not a small number of trees),
you should consider using TreeManager.disable_mptt_updates, as it does much fewer
queries.</p>
</dd>
<dt>Transactions:</dt>
<dd>This doesn&#8217;t enforce any transactional behavior.
You should wrap this in a transaction to ensure database consistency.</dd>
<dt>Exceptions:</dt>
<dd>If an exception occurs before the processing of the block, delayed updates
will not be applied.</dd>
</dl>
<p>Usage:</p>
<div class="highlight-python"><pre>with transaction.commit_on_success():
    with MyNode.objects.delay_mptt_updates():
        ## bulk updates.</pre>
</div>
</dd></dl>

<dl class="method">
<dt id="mptt.managers.TreeManager.disable_mptt_updates">
<tt class="descname">disable_mptt_updates</tt><big>(</big><em>*args</em>, <em>**kwds</em><big>)</big><a class="headerlink" href="#mptt.managers.TreeManager.disable_mptt_updates" title="Permalink to this definition"></a></dt>
<dd><p>Context manager. Disables mptt updates.</p>
<p>NOTE that this context manager causes inconsistencies! MPTT model methods are
not guaranteed to return the correct results.</p>
<dl class="docutils">
<dt>When to use this method:</dt>
<dd><p class="first">If used correctly, this method can be used to speed up bulk updates.</p>
<p>This doesn&#8217;t do anything clever. It <em>will</em> mess up your tree.
You should follow this method with a call to TreeManager.rebuild() to ensure your
tree stays sane, and you should wrap both calls in a transaction.</p>
<p class="last">This is best for updates that span a large part of the table.
If you are doing localised changes (1 tree, or a few trees) consider
using delay_mptt_updates.
If you are making only minor changes to your tree, just let the updates happen.</p>
</dd>
<dt>Transactions:</dt>
<dd>This doesn&#8217;t enforce any transactional behavior.
You should wrap this in a transaction to ensure database consistency.</dd>
</dl>
<p>If updates are already disabled on the model, this is a noop.</p>
<p>Usage:</p>
<div class="highlight-python"><pre>with transaction.commit_on_success():
    with MyNode.objects.disable_mptt_updates():
        ## bulk updates.
    MyNode.objects.rebuild()</pre>
</div>
</dd></dl>

<dl class="method">
<dt id="mptt.managers.TreeManager.get_query_set">
<tt class="descname">get_query_set</tt><big>(</big><big>)</big><a class="headerlink" href="#mptt.managers.TreeManager.get_query_set" title="Permalink to this definition"></a></dt>
<dd><p>Returns a <tt class="docutils literal"><span class="pre">QuerySet</span></tt> which contains all tree items, ordered in
such a way that that root nodes appear in tree id order and
their subtrees appear in depth-first order.</p>
</dd></dl>

<dl class="method">
<dt id="mptt.managers.TreeManager.get_queryset_descendants">
<tt class="descname">get_queryset_descendants</tt><big>(</big><em>queryset</em>, <em>include_self=False</em><big>)</big><a class="headerlink" href="#mptt.managers.TreeManager.get_queryset_descendants" title="Permalink to this definition"></a></dt>
<dd><p>Returns a queryset containing the descendants of all nodes in the
given queryset.</p>
<p>If <tt class="docutils literal"><span class="pre">include_self=True</span></tt>, nodes in <tt class="docutils literal"><span class="pre">queryset</span></tt> will also
be included in the result.</p>
</dd></dl>

<dl class="method">
<dt id="mptt.managers.TreeManager.init_from_model">
<tt class="descname">init_from_model</tt><big>(</big><em>model</em><big>)</big><a class="headerlink" href="#mptt.managers.TreeManager.init_from_model" title="Permalink to this definition"></a></dt>
<dd><p>Sets things up. This would normally be done in contribute_to_class(),
but Django calls that before we&#8217;ve created our extra tree fields on the
model (which we need). So it&#8217;s done here instead, after field setup.</p>
</dd></dl>

<dl class="method">
<dt id="mptt.managers.TreeManager.insert_node">
<tt class="descname">insert_node</tt><big>(</big><em>node</em>, <em>target</em>, <em>position=u'last-child'</em>, <em>save=False</em>, <em>allow_existing_pk=False</em><big>)</big><a class="headerlink" href="#mptt.managers.TreeManager.insert_node" title="Permalink to this definition"></a></dt>
<dd><p>Sets up the tree state for <tt class="docutils literal"><span class="pre">node</span></tt> (which has not yet been
inserted into in the database) so it will be positioned relative
to a given <tt class="docutils literal"><span class="pre">target</span></tt> node as specified by <tt class="docutils literal"><span class="pre">position</span></tt> (when
appropriate) it is inserted, with any neccessary space already
having been made for it.</p>
<p>A <tt class="docutils literal"><span class="pre">target</span></tt> of <tt class="docutils literal"><span class="pre">None</span></tt> indicates that <tt class="docutils literal"><span class="pre">node</span></tt> should be
the last root node.</p>
<p>If <tt class="docutils literal"><span class="pre">save</span></tt> is <tt class="docutils literal"><span class="pre">True</span></tt>, <tt class="docutils literal"><span class="pre">node</span></tt>&#8216;s <tt class="docutils literal"><span class="pre">save()</span></tt> method will be
called before it is returned.</p>
<p>NOTE: This is a low-level method; it does NOT respect <tt class="docutils literal"><span class="pre">MPTTMeta.order_insertion_by</span></tt>.
In most cases you should just set the node&#8217;s parent and let mptt call this during save.</p>
</dd></dl>

<dl class="attribute">
<dt id="mptt.managers.TreeManager.left_attr">
<tt class="descname">left_attr</tt><a class="headerlink" href="#mptt.managers.TreeManager.left_attr" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="mptt.managers.TreeManager.level_attr">
<tt class="descname">level_attr</tt><a class="headerlink" href="#mptt.managers.TreeManager.level_attr" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="mptt.managers.TreeManager.move_node">
<tt class="descname">move_node</tt><big>(</big><em>node</em>, <em>target</em>, <em>position=u'last-child'</em><big>)</big><a class="headerlink" href="#mptt.managers.TreeManager.move_node" title="Permalink to this definition"></a></dt>
<dd><p>Moves <tt class="docutils literal"><span class="pre">node</span></tt> relative to a given <tt class="docutils literal"><span class="pre">target</span></tt> node as specified
by <tt class="docutils literal"><span class="pre">position</span></tt> (when appropriate), by examining both nodes and
calling the appropriate method to perform the move.</p>
<p>A <tt class="docutils literal"><span class="pre">target</span></tt> of <tt class="docutils literal"><span class="pre">None</span></tt> indicates that <tt class="docutils literal"><span class="pre">node</span></tt> should be
turned into a root node.</p>
<p>Valid values for <tt class="docutils literal"><span class="pre">position</span></tt> are <tt class="docutils literal"><span class="pre">'first-child'</span></tt>,
<tt class="docutils literal"><span class="pre">'last-child'</span></tt>, <tt class="docutils literal"><span class="pre">'left'</span></tt> or <tt class="docutils literal"><span class="pre">'right'</span></tt>.</p>
<p><tt class="docutils literal"><span class="pre">node</span></tt> will be modified to reflect its new tree state in the
database.</p>
<p>This method explicitly checks for <tt class="docutils literal"><span class="pre">node</span></tt> being made a sibling
of a root node, as this is a special case due to our use of tree
ids to order root nodes.</p>
<p>NOTE: This is a low-level method; it does NOT respect <tt class="docutils literal"><span class="pre">MPTTMeta.order_insertion_by</span></tt>.
In most cases you should just move the node yourself by setting node.parent.</p>
</dd></dl>

<dl class="attribute">
<dt id="mptt.managers.TreeManager.parent_attr">
<tt class="descname">parent_attr</tt><a class="headerlink" href="#mptt.managers.TreeManager.parent_attr" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="mptt.managers.TreeManager.partial_rebuild">
<tt class="descname">partial_rebuild</tt><big>(</big><em>tree_id</em><big>)</big><a class="headerlink" href="#mptt.managers.TreeManager.partial_rebuild" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="mptt.managers.TreeManager.rebuild">
<tt class="descname">rebuild</tt><big>(</big><big>)</big><a class="headerlink" href="#mptt.managers.TreeManager.rebuild" title="Permalink to this definition"></a></dt>
<dd><p>Rebuilds whole tree in database using <cite>parent</cite> link.</p>
</dd></dl>

<dl class="attribute">
<dt id="mptt.managers.TreeManager.right_attr">
<tt class="descname">right_attr</tt><a class="headerlink" href="#mptt.managers.TreeManager.right_attr" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="mptt.managers.TreeManager.root_node">
<tt class="descname">root_node</tt><big>(</big><em>tree_id</em><big>)</big><a class="headerlink" href="#mptt.managers.TreeManager.root_node" title="Permalink to this definition"></a></dt>
<dd><p>Returns the root node of the tree with the given id.</p>
</dd></dl>

<dl class="method">
<dt id="mptt.managers.TreeManager.root_nodes">
<tt class="descname">root_nodes</tt><big>(</big><big>)</big><a class="headerlink" href="#mptt.managers.TreeManager.root_nodes" title="Permalink to this definition"></a></dt>
<dd><p>Creates a <tt class="docutils literal"><span class="pre">QuerySet</span></tt> containing root nodes.</p>
</dd></dl>

<dl class="attribute">
<dt id="mptt.managers.TreeManager.tree_id_attr">
<tt class="descname">tree_id_attr</tt><a class="headerlink" href="#mptt.managers.TreeManager.tree_id_attr" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

</dd></dl>

</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h4>Previous topic</h4>
  <p class="topless"><a href="mptt.forms.html"
                        title="previous chapter"><tt class="docutils literal docutils literal docutils literal"><span class="pre">mptt.forms</span></tt></a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="mptt.models.html"
                        title="next chapter"><tt class="docutils literal"><span class="pre">mptt.models</span></tt></a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="sources/mptt.managers.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="mptt.models.html" title="mptt.models"
             >next</a> |</li>
        <li class="right" >
          <a href="mptt.forms.html" title="mptt.forms"
             >previous</a> |</li>
        <li><a href="index.html">django-mptt 0.6.0 documentation</a> &raquo;</li>
          <li><a href="autogenerated.html" >Autogenerated documentation</a> &raquo;</li>
          <li><a href="mptt.html" ><tt class="docutils literal docutils literal docutils literal docutils literal docutils literal docutils literal docutils literal docutils literal"><span class="pre">mptt</span></tt></a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2007 - 2011, Jonathan Buchanan and others.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
    </div>
  </body>
</html>