Main mimerender decorator. Usage:
@mimerender(default='xml', override_arg_idx=-1, override_input_key='format', , <renderers>)
GET(self, ...) (or POST, etc.)
The decorated function must return a dict with the objects necessary to render the final result to the user. The selected renderer will be called with the dict contents as keyword arguments. If override_arg_idx isn’t None, the wrapped function’s positional argument at that index will be used instead of the Accept header. override_input_key works the same way, but with web.input().
Example:
@mimerender(
default = 'xml',
override_arg_idx = -1,
override_input_key = 'format',
xhtml = xhtml_templates.greet,
html = xhtml_templates.greet,
xml = xml_templates.greet,
json = json_render,
yaml = json_render,
txt = json_render,
)
def greet(self, param):
message = 'Hello, %s!'%param
return {'message':message}