diff options
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 e1c54c4..b7c01ce 100644 --- a/docs/source/hooks.rst +++ b/docs/source/hooks.rst @@ -54,17 +54,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. @@ -125,20 +123,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 ............................. @@ -179,25 +163,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 ....................... |