If there are any functions or objects defined in the root class they will be given piority over the index function when resolving urls. For instance if a root object had an function named foo defined in it, the url hostname/foo would be created by the returned result of that function. This is the case even if the index function was capable of accepting the agument foo. If foo was an object instead of a function the url hostname/foo would be resolved by the index method of the foo object. now consider the url hostname/foo/bar. This could be handled by in several ways if a object named foo is defined the page returned will be created by the function or object bar defined in foo. If foo is an function defined in the root object then bar will be a parameter passed to foo. There is no limit to the depth of the tree created in this way.
Posted by: Donald Johnson
| @ August 30, 2006 12:54:26 PM CDT ( ) |
The first level of handling is the index function of the root class. This function in its simplest form, controls what will be returned when just the domain name of the server is requested. When the index function takes only one parameter it will answer only for the domain name, however it may take parameters. If all parameters have default values the index function will still answer for the domain name otherwise the parameters will need to be given values in the url. values may be given by position or by name using the scheme ?paramname=value. The index function can defined to take an unknown number of parameters if defined with def index(self,*args). In this case the function would have to examine the arguments given and generate a page accordingly.
Posted by: Donald Johnson
| @ August 30, 2006 12:53:29 PM CDT ( ) |
Turbogears responds to URL request by traversing an internal function/object tree. The root of this tree is the class root defined in the code module controlers.py. Every turbogears project as its own controlers.py file. URLs are matched to the defined functions and objects of the root file. This terminates when a function is reached. The function matched in this way returns the web page.
Posted by: Donald Johnson
| @ August 30, 2006 12:43:41 PM CDT ( ) |
|
|

