Skip to content

Instantly share code, notes, and snippets.

@kenji4569
Created October 31, 2011 05:28
Show Gist options
  • Save kenji4569/1326961 to your computer and use it in GitHub Desktop.
Save kenji4569/1326961 to your computer and use it in GitHub Desktop.
descendants_from_node
def descendants_from_node(self, node, include_self=False):
db, table_node = self.db, self.settings.table_node
node = self._load_node(node)
left, right = node.left, node.right
if include_self:
left -= 1
right += 1
return db(table_node.left > left)(table_node.right < right)(
table_node.tree_id == node.tree_id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment