Skip to content

Commit

Permalink
add _drilldown_query method
Browse files Browse the repository at this point in the history
  • Loading branch information
uralbash committed Sep 13, 2015
1 parent e0acc5b commit 1884205
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def read(name):

setup(
name='sqlalchemy_mptt',
version='0.1.7',
version='0.1.8.dev1',
url='http://github.com/ITCase/sqlalchemy_mptt/',
author='Svintsov Dmitry',
author_email='[email protected]',
Expand Down
13 changes: 7 additions & 6 deletions sqlalchemy_mptt/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,12 @@ def get_node_id(node):
nodes_of_level[get_node_id(node)] = tree[-1]
return tree

def _drilldown_query(self, nodes):
table = self.__class__
return nodes.filter(table.tree_id == self.tree_id)\
.filter(table.left >= self.left)\
.filter(table.right <= self.right)

def drilldown_tree(self, session=None, json=False, json_fields=None):
""" This method generate a branch from a tree, begining with current
node.
Expand All @@ -269,13 +275,8 @@ def drilldown_tree(self, session=None, json=False, json_fields=None):
* :mod:`sqlalchemy_mptt.tests.cases.get_tree.test_drilldown_tree`
"""
def query(nodes):
table = self.__class__
return nodes.filter(table.tree_id == self.tree_id)\
.filter(table.left >= self.left)\
.filter(table.right <= self.right)
return self.get_tree(session, json=json, json_fields=json_fields,
query=query)
query=self._drilldown_query)

def path_to_root(self, session=None):
"""Generate path from a leaf or intermediate node to the root.
Expand Down

0 comments on commit 1884205

Please sign in to comment.