diff options
author | Ryan Petrello <lists@ryanpetrello.com> | 2013-08-08 14:16:36 -0400 |
---|---|---|
committer | Ryan Petrello <lists@ryanpetrello.com> | 2013-08-08 14:40:57 -0400 |
commit | fb2cf166aaf5b5af461879ec5b7a46806e8aee45 (patch) | |
tree | 55e258c72fc496b79d77c6d43e0750c752b89cec /docs | |
parent | 38c64ff3518470ff668a06725abb4d2f2d5ab7ba (diff) | |
download | pecan-fb2cf166aaf5b5af461879ec5b7a46806e8aee45.tar.gz |
Make some notable changes to how ``pecan.conf.app`` is passed to a new app.
* Now pecan.conf.app items are treated as keywords passed directly to Pecan
apps. This means no more tinkering with *both* your configuration file *and*
your app.py file.
* Removed support for the RequestViewerHook config file shortcut (because now
you can easily specify hooks via configuration).
Diffstat (limited to 'docs')
-rw-r--r-- | docs/source/hooks.rst | 41 |
1 files changed, 8 insertions, 33 deletions
diff --git a/docs/source/hooks.rst b/docs/source/hooks.rst index 9a9d099..3185355 100644 --- a/docs/source/hooks.rst +++ b/docs/source/hooks.rst @@ -52,17 +52,15 @@ Attaching Hooks --------------- Hooks can be attached in a project-wide manner by specifying a list of hooks -in your project's ``app.py`` file. +in your project's configuration file. :: - from application.root import RootController - from my_hooks import SimpleHook - - app = make_app( - RootController(), - hooks = [SimpleHook()] - ) + app = { + 'root' : '...' + # ... + 'hooks': lambda: [SimpleHook()] + } Hooks can also be applied selectively to controllers and their sub-controllers using the :attr:`__hooks__` attribute on one or more controllers. @@ -123,20 +121,6 @@ By default, both outputs are enabled. * :ref:`pecan_hooks` -Enabling RequestViewerHook -.......................... - -This hook can be automatically added to the application itself if a certain -key, ``requestviewer``, exists in the configuration used for the app, e.g.:: - - app = {} - server = {} - requestviewer = {} - -It does not need to contain anything (could be an empty dictionary), and this -is enough to force Pecan to load this hook when the WSGI application is -created. - Configuring RequestViewerHook ............................. @@ -177,25 +161,16 @@ response:: X-Pecan-params [] X-Pecan-hooks ['RequestViewerHook'] -The hook can be configured via a dictionary (or Config object from Pecan) when -adding it to the application or via the ``requestviewer`` key in the actual -configuration being passed to the application. - The configuration dictionary is flexible (none of the keys are required) and can hold two keys: ``items`` and ``blacklist``. -This is how the hook would look if configured directly when using ``make_app`` -(shortened for brevity):: +This is how the hook would look if configured directly (shortened for brevity):: ... - hooks = [ + 'hooks': lambda: [ RequestViewerHook({'items':['path']}) ] -And the same configuration could be set in the config file like:: - - requestviewer = {'items:['path']} - Modifying Output Format ....................... |