Package tdi :: Module nodetree :: Class Root
[frames] | no frames]

Class Root

source code

  object --+    
           |    
TemplateNode --+
               |
              Root

Root Node class

This class has to be used as the initial root of the tree.

Instance Methods
 
__init__(self)
Initialization
source code
 
__str__(self)
String representation of the tree
source code
str
to_string(self, verbose=False)
String representation of the tree
source code
 
finalize(self, encoder, decoder)
Finalize the tree
source code
 
overlay(self, other)
Overlay this tree with another one
source code
iterable
render(self, model, startnode=None)
Render the tree into chunks, calling model for input
source code

Inherited from TemplateNode: append_escape, append_node, append_text

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Class Variables

Inherited from TemplateNode: ctx

Properties
EncoderInterface encoder
Output encoder
DecoderInterface decoder
Input decoder
iterable source_overlay_names
Source overlay names
iterable target_overlay_names
Target overlay names

Inherited from TemplateNode: endtag

Inherited from object: __class__

Method Details

__init__(self)
(Constructor)

source code 
Initialization
Parameters:
  • tagname - The name of the accompanying tag
  • attr - The attribute list (((name, value), ...))
  • special - Special node information
Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 
String representation of the tree
Overrides: object.__str__

to_string(self, verbose=False)

source code 
String representation of the tree
Parameters:
  • verbose (bool) - Show (shortened) text node content and separator nodes?
Returns: str
The string representation

finalize(self, encoder, decoder)

source code 

Finalize the tree

This method assigns separator nodes to their accompanying content nodes, concatenates adjacent text nodes and tries to optimize the tree a bit.

Parameters:
Raises:
  • NodeTreeError - The tree was already finalized or endtag was not set

overlay(self, other)

source code 
Overlay this tree with another one
Parameters:
  • other (Root) - The tree to lay over
Raises:

render(self, model, startnode=None)

source code 
Render the tree into chunks, calling model for input
Parameters:
  • model (ModelAdapterInterface) - The model object
  • startnode (str) - Only render this node (and all its children). The node is addressed via a dotted string notation, like a.b.c (this would render the c node.) The notation does not describe a strict node chain, though. Between to parts of a node chain may be gaps in the tree. The algorithm looks out for the first matching node. It does no backtracking and so does not cover all branches (yet?), but that works fine for realistic cases :). A non-working example would be (searching for a.b.c):

    *
    +- a
    |  `- b - d
    `- a
       `- b - c
    
Returns: iterable
Rendered chunks

Property Details

encoder

Output encoder
Get Method:
unreachable.fget(self)
Type:
EncoderInterface

decoder

Input decoder
Get Method:
unreachable.fget(self)
Type:
DecoderInterface

source_overlay_names

Source overlay names
Get Method:
unreachable.fget(self)
Type:
iterable

target_overlay_names

Target overlay names
Get Method:
unreachable.fget(self)
Type:
iterable