check webob docs
Route for URL paths
A route template to match against the request path. A template can have variables enclosed by <> that define a name, and and optional regular expression. Examples:
Format Example <name> '/blog/<year>/<month>' <name:regex> '/blog/<year:\d{4}>/<month:\d{2}>'
The value of the matched regular expression is passed as keyword argument to the handler.
If only the name is set, it will match anything except a slash. So these routes are equivalent:
Route('/<user_id>/settings', handler=SettingsHandler,
name='user-settings')
Route('/<user_id:[^/]+>/settings', handler=SettingsHandler,
name='user-settings')
Parameters: |
|
---|
MatchResult(route, kwargs)
A URI router used to match and build URIs.
Initializes the router.
Parameters: | routes – A sequence of (Route, :str:name) instances |
---|
Adds a route to this router.
Parameters: | route – A Route instance or, for simple routes, a tuple (regex, handler). |
---|
Returns a URI for a named Route.
Parameters: |
|
---|---|
Returns: | (string) An absolute or relative URI. |
Base HTTP request handler - this should be subclassed
Attributes: app, request, response are references.
Subclasses should implement the handled HTTP methods (get, post, ...). The handler methods take *args, **kwargs from its route values.
Subclasses may overwrite the handle_exception method.
The methods redirect, uri_for and redirect_to are helpers to be used on handler methods.
The wsgi application executes the handler using the dispatch method. This can also be subclassed to add to some extra stuff.
Execute the handler method (get, post, ...)
Sets the response attribute.
Parameters: |
|
---|
Called if this handler throws an exception during execution.
The default behavior is to re-raise the exception to be handled by WSGIApplication._handle_exception().
Parameters: | exception – The exception that was thrown. |
---|
sets the response with HTTP redirect to the given relative URI.
Parameters: |
|
---|
Convenience method mixing redirect() and uri_for().
The arguments are described in redirect() and uri_for().
Shortcut to build a URI from app router
see also avalanche.router.Router.build()
A WSGI application
Initializes the WSGI application.
Parameters: |
|
---|
Any object that implements that implements a render method. render method takes 2 parameters:
- handler: a reference
- context: a dictionary
Avalanche comes with a few renderers:
No operation renderer, to be used when handler writes no response
User’s should create handlers by subclassing BaseHandler.
make_handler result should be used on the WSGIApplication.
creates a concrete request handler => ApplicationHandler(avalanche.Handler) + _AvalancheHandler + core.RequestHandler
avalanche functionality.
Users should not subclass this directly, use make_handler
list of context-builder method names used on GET requests
list of context-builder method names used on POST requests
A renderer instance
(string) path to jinja template to be rendered
Base class that user should subclass when creating request handlers
used to modify config values inherited from a base class
config values are saved as a dict in the attribute ‘a_config’.
- on first level keys are the name of config-builders
- on second level keys are the parameter names
- values are instances of AvalancheParam
class MyHandler(MyHandlerBase):
@classmethod
def set_config(cls):
cls.a_config['builder_a']['x'] = avalanche.UrlQueryParam('x', 'x2')
A parameter converter - (Abstract base class)
This is used to convert parameters (i.e. from the URL) from string to its real type.
Parameters: | obj_name (str) – name of param to be passed to context_builders |
---|
get parameter from URL path (given by route)
Parameters: |
|
---|
get parameter from the URL query string