pecan.decorators – Pecan Decorators¶
pecan.decorators module includes useful decorators for
creating Pecan applications.
expose(template=None, generic=False, route=None, **kw)¶
Decorator used to flag controller methods as being “exposed” for access via HTTP, and to configure that access.
- template – The path to a template, relative to the base template
directory. Can also be passed a string representing
a special or custom renderer, such as
'json'for The JSON Renderer.
- content_type – The content-type to use for this template.
- generic – A boolean which flags this as a “generic” controller,
which uses generic functions based upon
functools.singledispatchgeneric functions. Allows you to split a single controller into multiple paths based upon HTTP method.
- route – The name of the path segment to match (excluding separator characters, like /). Defaults to the name of the function itself, but this can be used to resolve paths which are not valid Python function names, e.g., if you wanted to route a function to `some-special-path’.
- template – The path to a template, relative to the base template directory. Can also be passed a string representing a special or custom renderer, such as
If utilizing the
TransactionHook, allows you to flag a controller method or class as being wrapped in a transaction, regardless of HTTP method.
Parameters: ignore_redirects – Indicates if the hook should ignore redirects for this controller or not.
Flags a controller method as accepting non-canoncial URLs.
If utilizing the
TransactionHook, allows you to flag a controller method to perform a callable action after the commit is successfully issued.
Parameters: action – The callable to call after the commit is successfully issued.