From: Jason Kirtland Date: Tue, 21 Aug 2007 21:05:23 +0000 (+0000) Subject: Updated adjencytree examples X-Git-Tag: rel_0_4beta4~16 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0051349d09a95d48feefc6ebdca832a3919c5817;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Updated adjencytree examples --- diff --git a/examples/adjacencytree/basic_tree.py b/examples/adjacencytree/basic_tree.py index 53bdc82983..c6f49ccaea 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 a61bde8757..e6e57b5aa1 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:"