5.3.10.6 TreeNode Objects
Description: TreeNode Objects
Keywords: albatross

###
5.3.10.6 TreeNode Objects

There is no actual `TreeNode` class. Trees can be constructed from objects of any class as long as they implement the interface described here.

`children`
  This member must only be present in non leaf nodes. It contains a list of immediate child nodes of this node.

  When using lazy loaded trees this member should be initialised to an empty list in the constructor. The presence of the `children` member makes the toolkit treat the node as a non-leaf node.

`children_loaded`
  This member needs only be present in non leaf nodes that are referenced by an `<al-tree>` tag in lazy mode. It should be initialised to `0` in the node constructor. The toolkit will set the member to `1` once it has called the `load_children()` method of the node.

`load_children`( | ctx)

  This method must be defined for nodes that are referenced by an `<al-tree>` tag in lazy mode. It should must populate the `children` member with the immediate child nodes.

  The toolkit will call this method when it needs to display the child nodes of a node and they have not yet been loaded (`children_loaded``== 0`).

  The toolkit ``knows'' when it needs to see the child nodes of a particular node so it asks that node to load the children. This allows potentially huge trees to be browsed by having the toolkit only load those nodes that are visible.

`albatross_alias`( | )

  This method must be defined for nodes that are referenced by an `<al-tree>` tag in lazy mode. It must return a unique string identifier for this node that is suitable for use as part of an HTML input field name or URL component via the special `treeselect`, `treefold` and `treeellipsis` attributes. The identifier must be the same each time the program is run (so `str(id(self))` will not work).

  The `TreeIterator` uses the node identifier to record which nodes are open and which are selected. The same identifier is also used when the node is referenced via an `alias` (5.2.2.1) attribute of an `<al-input>` tag.