summaryrefslogtreecommitdiff
path: root/examples/adjacencytree/byroot_tree.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2005-10-17 00:12:30 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2005-10-17 00:12:30 +0000
commitd9d39f0a8de4bc94f5c6b1a8cbc9f17d0ec511d8 (patch)
treea4d9aefc856dcc7343697ef6ca4377772439e8fd /examples/adjacencytree/byroot_tree.py
parent988bf12461740244f8a4baef52779cf79eea48e0 (diff)
downloadsqlalchemy-d9d39f0a8de4bc94f5c6b1a8cbc9f17d0ec511d8.tar.gz
Diffstat (limited to 'examples/adjacencytree/byroot_tree.py')
-rw-r--r--examples/adjacencytree/byroot_tree.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/examples/adjacencytree/byroot_tree.py b/examples/adjacencytree/byroot_tree.py
index 4d767af59..cf8b7cbbb 100644
--- a/examples/adjacencytree/byroot_tree.py
+++ b/examples/adjacencytree/byroot_tree.py
@@ -41,6 +41,7 @@ class TreeNode(object):
self.root = self
self.parent = None
self.id = None
+ self.data =None
self.parent_id = None
self.root_id=None
def _set_root(self, root):
@@ -57,7 +58,7 @@ class TreeNode(object):
def __str__(self):
return self._getstring(0, False)
def _getstring(self, level, expand = False):
- s = (' ' * level) + "%s (%s,%s,%s, %d)" % (self.name, self.id,self.parent_id,self.root_id, id(self)) + '\n'
+ s = (' ' * level) + "%s (%s,%s,%s, %d): %s" % (self.name, self.id,self.parent_id,self.root_id, id(self), repr(self.data)) + '\n'
if expand:
s += string.join([n._getstring(level+1, True) for n in self.children.values()], '')
return s
@@ -97,16 +98,14 @@ class TreeData(object):
self.value = value
def __repr__(self):
return "TreeData(%s, %s)" % (repr(self.id), repr(self.value))
-# define the mapper. we will make "convenient" property
-# names vs. the more verbose names in the table definition
TreeNode.mapper=assignmapper(tables.trees, properties=dict(
id=tables.trees.c.node_id,
name=tables.trees.c.node_name,
parent_id=tables.trees.c.parent_node_id,
root_id=tables.trees.c.root_node_id,
- root=relation(TreeNode, primaryjoin=tables.trees.c.root_node_id==tables.trees.c.node_id, foreignkey=tables.trees.c.node_id, thiscol=tables.trees.c.root_node_id, lazy=None, uselist=False),
- children=relation(TreeNode, primaryjoin=tables.trees.c.parent_node_id==tables.trees.c.node_id, foreignkey=tables.trees.c.parent_node_id, thiscol=tables.trees.c.node_id, lazy=None, uselist=True, private=True),
+ root=relation(TreeNode, primaryjoin=tables.trees.c.root_node_id==tables.trees.c.node_id, foreignkey=tables.trees.c.node_id, lazy=None, uselist=False),
+ children=relation(TreeNode, primaryjoin=tables.trees.c.parent_node_id==tables.trees.c.node_id, lazy=None, uselist=True, private=True),
data=relation(TreeData, tables.treedata, properties=dict(id=tables.treedata.c.data_id), private=True, lazy=False)
), extension = TreeLoader())