]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
(no commit message)
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 14 Oct 2005 09:35:29 +0000 (09:35 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 14 Oct 2005 09:35:29 +0000 (09:35 +0000)
examples/adjacencytree/byroot_tree.py

index 06b74d7b71d1842f2cf3957d34e67994a8c4bdf9..a98b19368515c32a9f3efff17f707b933310435c 100644 (file)
@@ -9,9 +9,10 @@ import string, sys
 add application-specific functionality to a Mapper object."""
 
 class NodeList(util.OrderedDict):
-    """extends an Ordered Dictionary, which is just a dictionary that returns its keys and values
-    in order upon iteration.  Adds functionality to automatically associate 
-    the parent of a TreeNode with itself, upon append to the parent's list of child nodes."""
+    """extends an Ordered Dictionary, which is just a dictionary that iterates its keys and values
+    in the order they were inserted.  Adds an "append" method, which appends a node to the 
+    dictionary as though it were a list, and also within append automatically associates 
+    the parent of a TreeNode with itself."""
     def __init__(self, parent):
         util.OrderedDict.__init__(self)
         self.parent = parent
@@ -35,8 +36,8 @@ class TreeNode(object):
     def __init__(self, name):
         """for data integrity, a TreeNode requires its name to be passed as a parameter
         to its constructor, so there is no chance of a TreeNode that doesnt have a name."""
-        self.children = NodeList(self)
         self.name = name
+        self.children = NodeList(self)
         self.root = self
         self.parent = None
         self.id = None