Skip to content

Commit

Permalink
++docs
Browse files Browse the repository at this point in the history
  • Loading branch information
uralbash committed Jun 25, 2015
1 parent cb11357 commit b0bc94d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion sqlalchemy_mptt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .mixins import BaseNestedSets
from .events import TreesManager

__version__ = "0.1.5"
__version__ = "0.1.6.dev1"
__mixins__ = [BaseNestedSets]
__all__ = ['BaseNestedSets', 'mptt_sessionmaker']

Expand Down
44 changes: 25 additions & 19 deletions sqlalchemy_mptt/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ def _node_to_dict(cls, node, json, json_fields):

@classmethod
def get_tree(cls, session=None, json=False, json_fields=None, query=None):
""" This function generate tree of current node in dict or json format.
""" This method generate tree of current node table in dict or json
format. You can make custom query with attribute ``query``. By default
it return all nodes in table.
Args:
session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session
Expand Down Expand Up @@ -231,24 +233,28 @@ def get_node_id(node):
return tree

def drilldown_tree(self, session=None, json=False, json_fields=None):
"""
node7.drilldown_tree()
.. code::
level Nested sets example
1 1(1)22 ---------------------
_______________|_________|_________ |
| | | | |
2 2(2)5 6(4)11 | 12(7)21 |
| ^ | ^ |
3 3(3)4 7(5)8 9(6)10 | 13(8)16 17(10)20 |
| | | |
4 | 14(9)15 18(11)19 |
| |
---------------------
""" This method generate a branch from a tree, begining with current
node.
Example:
For example:
node7.drilldown_tree()
.. code::
level Nested sets example
1 1(1)22 ---------------------
_______________|_________|_________ |
| | | | |
2 2(2)5 6(4)11 | 12(7)21 |
| ^ | ^ |
3 3(3)4 7(5)8 9(6)10 | 13(8)16 17(10)20 |
| | | |
4 | 14(9)15 18(11)19 |
| |
---------------------
Example in tests:
* :mod:`sqlalchemy_mptt.tests.cases.get_tree.test_drilldown_tree`
"""
Expand All @@ -262,7 +268,7 @@ def query(nodes):

@classmethod
def rebuild_tree(cls, session, tree_id):
""" This function rebuid tree.
""" This method rebuid tree.
Args:
session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session
Expand Down

0 comments on commit b0bc94d

Please sign in to comment.