children and maximum nesting level (see :class:`MPManager` to learn
more about limits fine-tuning) is done during session flush.
* Rebuilding all trees (see :meth:`MPClassManager.rebuild_all_trees`)
- and any subtree (:meth:`MPClassManager.rebuild_subtree`) on the
- basis of Adjacency Relations.
+ on the basis of Adjacency Relations.
* Collapsing flat tree returned from query to recursive structure (see
* Node classes may use `polymorphic inheritance
depth, tree_id, path, depth)
- def rebuild_subtree(self, session, root_node_id, order_by=None):
- Reset paths for all nodes in subtree defined by `root_node_id`
- on the basis of adjacency relations.
- session object for DML queries.
- the value of subtree root's primary key.
- an "order by clause" for sorting children nodes
- :meth:`rebuild_subtree` didn't receive ``session`` parameter
- path, depth, tree_id = session.execute(sqlalchemy.select(
- [opts.path_field, opts.depth_field, opts.tree_id_field],
- opts.pk_field == root_node_id
- order_by = opts.pk_field
- session, root_node_id, path, depth, tree_id, order_by
def _do_rebuild_subtree(self, session, root_node_id, root_path,
root_depth, tree_id, order_by):