Routing#
Router#
- class trytond.routing.Router#
This is the base class that every router inherits.
Class attributes are:
- Router.__name__#
The unique name to reference the router throughout the platform.
- Router.rules#
A mapping between the name of callable endpoint and the list of rules.
Class methods:
- classmethod Router.url_for(endpoint[, _method[, _request[, \*\*values]]])#
Generate a URL to the given
endpointwith the givenvalues.endpointis the name of the callable endpoint.valuesis used for the variable parts of the URL rule. Unknown keys are appended as query string arguments._methodif given, generate the URL associated with this method for the endpoint._requestif given, the request context to use to generate the base of the URL.
Route#
- class trytond.routing.Route(\*rules[, decorators])#
This class is used to define a set of Rule that maps variable
placeholders to their value in the URL.
Route allows also to set decorators that are applied to the endpoint method following the declaration order.
Class attributes are:
Instance method:
Rule#
- class trytond.routing.Rule(path[, methods[, defaults[, redirect_to]]])#
This class is a named tuple defining the path, methods, default values and
redirect URL of a rule. Those parameters have the same meaning as those of a
Werkzeug Rule with the exception of redirect_to which must be a string.
There are two kinds of rule:
relative rule is a rule for which the path does not start with a
/. The path will be prefixed by/<database>/r/<router>/wheredatabaseandrouterare expended to the database name and the router’sRouter.__name__respectively to create the database rule.absolute rule is a rule for which the path starts with a
/. The path is used as-is to create the Werkzeug rule in this case.