The main resolver class for Pushrod.
Parameters: | renderers – A tuple of renderers that are registered immediately (can also be strings, which are currently expanded to flask.ext.pushrod.renderers.%s_renderer) |
---|
The current app, only set from the constructor, not if using init_app().
The query string argument checked for an explicit renderer (to override header-based content type negotiation).
Note
This is set on the class level, not the instance level.
Inspects a Flask Request for hints regarding what renderer to use.
Parameters: | request – The request to be inspected (defaults to flask.request) |
---|---|
Returns: | List of matching renderers, in order of user preference |
Registers the Pushrod resolver with the Flask app (can also be done by passing the app to the constructor).
Gets the logger to use, mainly for internal use.
The current resolution order looks as follows:
The renderers keyed by MIME type.
The renderers keyed by output format name (such as html).
Runs an object through the normalizer mechanism, with the goal of producing a value consisting only of “native types” (unicode, int, long, float, dict, list, etc).
The resolution order looks like this:
See Bundled Normalizers for all default normalizers.
Parameters: | obj – The object to normalize. |
---|
Hooks for overriding a class’ normalizer, even if they explicitly define one.
All items should be lists of callables. All values default to an empty list.
Hooks for providing a class with a fallback normalizer, which is called only if it doesn’t define one. All items should be callables.
Registers a renderer with the Pushrod resolver (can also be done by passing the renderer to the constructor).
Renders an unrendered response (a bare value, a (response, status, headers)-tuple, or an UnrenderedResponse object).
Throws RendererNotFound: | |
---|---|
If a usable renderer could not be found (explicit renderer argument points to an invalid render, or no acceptable mime types can be used as targets and there is no default renderer) |
|
Parameters: |
|
Note
For convenience, a bare string (unicode, str, or any other basestring derivative), or a derivative of werkzeug.wrappers.BaseResponse (such as flask.Response) is passed through unchanged.
Note
A renderer may mark itself as unable to render a specific response by returning None, in which case the next possible renderer is attempted.
Decorator that wraps view functions and renders their responses through flask.ext.pushrod.Pushrod.render_response().
Note
Views should only return dicts or a type that normalizes down to dicts.
Parameters: | renderer_kwargs – Any extra arguments to pass to the renderer |
---|
Flags a function as a Pushrod renderer.
Note
Before it is recognized by flask.ext.pushrod.Pushrod.get_renderers_for_request() (and, by extension, render_response()) it must be registered to the app’s Pushrod instance (using register_renderer(), or passed as part of the renderers argument to the Pushrod constructor).
Parameters: |
|
---|
Holds basic response data from the view function until it is processed by the renderer.
Constructs a rendered_class (flask.Response by default) based on the response parameters.
The class to construct with the rendered response, defaults to flask.Response.
alias of Response
Renders a response using json.dumps().
Renderer MIME type triggers: | |
---|---|
|
|
Renderer name triggers: | |
|
Renders a response using flask.render_template().
Renderer MIME type triggers: | |
---|---|
|
|
Renderer name triggers: | |
|
Flask-Pushrod ships with a few normalizers by default. For more info, see normalize().
Flask-Pushrod’s built-in normalizers are generally named with the scheme normalize_type.
Note
Normalizers also apply to subclasses, unless the subclass defines another normalizer.
Takes : | |
---|---|
Returns: | list with all values normalized |
Takes : | dict |
---|---|
Returns: | dict with all keys converted to unicode and then normalized and all values normalized |
Delegates normalization to the object itself, looking for the following attributes/methods (in this order):
Note
__pushrod_fields__ and __pushrod_field__ can be either a callable or an attribute, while __pushrod_normalize__ must be a callable.
Takes : | object |
---|
Thrown when no acceptable renderer can be found, see flask.ext.pushrod.Pushrod.get_renderers_for_request().
Note
This class inherits from werkzeug.exceptions.NotAcceptable, so it’s automatically converted to 406 Not Acceptable by Werkzeug if not explicitly handled (which is usually the intended behaviour).