diff options
| author | Jason Kirtland <jek@discorporate.us> | 2007-08-21 21:05:23 +0000 |
|---|---|---|
| committer | Jason Kirtland <jek@discorporate.us> | 2007-08-21 21:05:23 +0000 |
| commit | 0051349d09a95d48feefc6ebdca832a3919c5817 (patch) | |
| tree | b9955e67a533089b8d1743b07dceb6611f28b660 /examples | |
| parent | 72efa9db3a2591a36de69158435df9f4bb67ee15 (diff) | |
| download | sqlalchemy-0051349d09a95d48feefc6ebdca832a3919c5817.tar.gz | |
Updated adjencytree examples
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/adjacencytree/basic_tree.py | 2 | ||||
| -rw-r--r-- | examples/adjacencytree/byroot_tree.py | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/examples/adjacencytree/basic_tree.py b/examples/adjacencytree/basic_tree.py index 53bdc8298..c6f49ccae 100644 --- a/examples/adjacencytree/basic_tree.py +++ b/examples/adjacencytree/basic_tree.py @@ -113,7 +113,7 @@ print "tree new where node_id=%d:" % nodeid print "----------------------------" session.clear() -t = session.query(TreeNode).select(TreeNode.c.id==nodeid)[0] +t = session.query(TreeNode).filter(TreeNode.c.id==nodeid)[0] print "\n\n\n----------------------------" print "Full Tree:" diff --git a/examples/adjacencytree/byroot_tree.py b/examples/adjacencytree/byroot_tree.py index a61bde875..e6e57b5aa 100644 --- a/examples/adjacencytree/byroot_tree.py +++ b/examples/adjacencytree/byroot_tree.py @@ -48,7 +48,7 @@ class TreeNode(object): if isinstance(node, str): node = TreeNode(node) node._set_root(self.root) - self.children.append(node) + self.children.set(node) def __repr__(self): return self._getstring(0, False) @@ -90,8 +90,8 @@ class TreeLoader(MapperExtension): result.append(instance) else: if isnew or selectcontext.populate_existing: - parentnode = selectcontext.identity_map[mapper.identity_key(instance.parent_id)] - parentnode.children.append(instance) + parentnode = selectcontext.identity_map[mapper.identity_key_from_primary_key(instance.parent_id)] + parentnode.children.set(instance) return False class TreeData(object): @@ -196,7 +196,7 @@ session.clear() # load some nodes. we do this based on "root id" which will load an entire sub-tree in one pass. # the MapperExtension will assemble the incoming nodes into a tree structure. -t = session.query(TreeNode).select(TreeNode.c.root_id==nodeid, order_by=[TreeNode.c.id])[0] +t = session.query(TreeNode).filter(TreeNode.c.root_id==nodeid).order_by([TreeNode.c.id])[0] print "\n\n\n----------------------------" print "Full Tree:" |
