pecan.decorators – Pecan Decorators

The pecan.decorators module includes useful decorators for creating Pecan applications.

pecan.decorators.expose(template=None, content_type='text/html', generic=False)

Decorator used to flag controller methods as being “exposed” for access via HTTP, and to configure that access.

Parameters:
  • template – The path to a template, relative to the base template directory.
  • 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.singledispatch generic functions. Allows you to split a single controller into multiple paths based upon HTTP method.
pecan.decorators.transactional(ignore_redirects=True)

If utilizing the pecan.hooks 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.
pecan.decorators.accept_noncanonical(func)

Flags a controller method as accepting non-canoncial URLs.

pecan.decorators.after_commit(action)

If utilizing the pecan.hooks 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.
pecan.decorators.after_rollback(action)

If utilizing the pecan.hooks TransactionHook, allows you to flag a controller method to perform a callable action after the rollback is successfully issued.

Parameters:action – The callable to call after the rollback is successfully issued.

Previous topic

pecan.configuration – Pecan Configuration Engine

Next topic

pecan.deploy – Pecan Deploy

This Page