Route Manager¶
-
class
routing.RouteManager(server_protocol='http', server_address='localhost', server_port=None, url_prefix='/')[source]¶ Class storing and managing Route objects.
-
add_route(route)[source]¶ Add a new route to the dictionary ROUTES.
Parameters: route – A Route object Raises: KeyError – If ‘name’ of the Route object to be added is the same of another Route object already in the dictionary
-
expose_route(route_name, url_prefix=None)[source]¶ Expose all the properties of an existing route, formatted as a dictionary.
Parameters: - route_name – A string matching the ‘name’ key of the route to be returned
- url_prefix – A string add as a prefix when returning the ‘url’ property of the Route object
Returns: A dictionary with all the properties inside the Route object looked for
Raise: KeyError (if no Route object matching the ‘route_name’ parameter is found)
-
expose_route2(route_name, url_prefix=None, additional_parameters=None)[source]¶ Expose all the properties of an existing route, formatted as a dictionary.
Parameters: - route_name – A string matching the ‘name’ key of the route to be returned
- url_prefix – A string add as a prefix when returning the ‘url’ property of the Route object
- additional_parameters – A dictionary with additional key-value arguments to be exposed
Returns: A dictionary with all the properties inside the Route object looked for
Raise: KeyError (if no Route object matching the ‘route_name’ parameter is found)
-
get_javascript_routes(template_name, template_path, route_list=None, additional_context=None)[source]¶ Render a template file using Jinja.
Parameters: - template_name – The name of the template file
- template_path – The absolute path of the template file (omitting the name of the template file)
- route_list – A list of Route objects, used to render the template (OPTIONAL)
- additional_context – A dictionary that will extend the context used to render the template (OPTIONAL)
Returns: The template file rendered as a string (with a default template variable called “routes” that stores a list of Route objects)
-