How does the Control work?
very control has a
output function which is called which returns a
representation of the HTML to be displayed (i.e. raw HTML strings, or OUTPUT objects). When the
output(self,display,container) method is called it
does the following
- Calls display.fetch_records(). It returns a list of dictionaries .
Usually fetch_records executes an sql query, modifies each dictionary (if
need be), and returns the list of dictionaries.
- Unflattens this and constructs a tree representation of the data. Each
node has all the information which was originally there.
- Creates an instance of TheNodeControl (some descendent of NodeControl),
which was passed in as a argument of __init__ of this control.
NodeControls can have children which are controls. So this is used to
create a tree of NodeControls, where each node in the tree is instantiated
with the corresponding data.
- Finally it calls the output method of the top level instance of
TheNodeControl. Each instance of NodeControl is responsible for making
sure that its children get called (if need be).