File tree Expand file tree Collapse file tree 1 file changed +48
-3
lines changed
Expand file tree Collapse file tree 1 file changed +48
-3
lines changed Original file line number Diff line number Diff line change 22[ ![ Coverage Status] ( https://coveralls.io/repos/ITCase/sqlalchemy_mptt/badge.png )] ( https://coveralls.io/r/ITCase/sqlalchemy_mptt )
33[ ![ Stories in Ready] ( https://badge.waffle.io/itcase/sqlalchemy_mptt.png?label=ready&title=Ready )] ( https://waffle.io/itcase/sqlalchemy_mptt )
44
5- soon.. .
5+ Library for implementing Modified Preorder Tree Traversal with your SQLAlchemy Models and working with trees of Model instances, like django-mptt .
66
7- ![ ScreenShot] ( https://rawgithub.com/ITCase/sqlalchemy_mptt/master/docs/img/1_sqlalchemy_mptt_example.svg )
8- ![ ScreenShot] ( https://rawgithub.com/ITCase/sqlalchemy_mptt/master/docs/img/2_sqlalchemy_mptt_traversal.svg )
7+ ![ Nested sets example] ( https://rawgithub.com/ITCase/sqlalchemy_mptt/master/docs/img/1_sqlalchemy_mptt_example.svg )
8+
9+ The nested set model is a particular technique for representing nested sets (also known as trees or hierarchies) in relational databases.
10+
11+ ![ Nested sets traversal] ( https://rawgithub.com/ITCase/sqlalchemy_mptt/master/docs/img/2_sqlalchemy_mptt_traversal.svg )
12+
13+ Installing
14+ ----------
15+
16+ Install from github:
17+
18+ pip install git+http://github.com/ITCase/sqlalchemy_mptt.git
19+
20+ PyPi:
21+
22+ pip install sqlalchemy_mptt
23+
24+ Source:
25+
26+ python setup.py install
27+
28+ Usage
29+ -----
30+
31+ Add mixin to model
32+
33+ ``` python
34+ from sqlalchemy import Column, Integer, Boolean
35+ from sqlalchemy.ext.declarative import declarative_base
36+
37+ from sqlalchemy_mptt.mixins import BaseNestedSets
38+
39+ Base = declarative_base()
40+
41+
42+ class Tree (Base , BaseNestedSets ):
43+ __tablename__ = " tree"
44+
45+ id = Column(Integer, primary_key = True )
46+ visible = Column(Boolean)
47+
48+ def __repr__ (self ):
49+ return " <Node (%s )>" % self .id
50+
51+ Tree.register_tree()
52+ ```
53+ Now you can add, move and delete obj
You can’t perform that action at this time.
0 commit comments