Skip to content

Commit

Permalink
Improve hooks documentation and add before_config and after_config hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
amol- committed Nov 20, 2011
1 parent 00fe032 commit d529b6e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions docs/main/Config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ of the ``base_config`` object in your ``app_cfg.py`` file::
base_config.register_hook('shutdown', on_shutdown)
base_config.register_hook('before_render', before_render)

To register controller based hook you can use the event decorators::
To register controller based hooks you can use the event decorators::

from tg.decorators import before_render

Expand All @@ -261,10 +261,19 @@ To register controller based hook you can use the event decorators::
def index(self, *args, **kw):
return dict(page='index')

Available events are:
Available Hooks
####################

* ``startup()`` - application wide only, called when the application starts
* ``shutdown()`` - application wide only, called when the application exits
* ``shutdown()`` - application wide only, called when the application exits
* ``before_config(app) -> app`` - application wide only, called after constructing the application,
but before setting up most of the options and middleware.
Must return the application itself.
Can be used to wrap the application into middlewares that have to be executed having the full TG stack available.
* ``after_config(app) -> app`` - application wide only, called after finishing setting everything up.
Must return the application iself.
Can be used to wrap the application into middleware that have to be executed before the TG ones.
Can also be used to modify the Application by mounting additional subcontrollers inside the RootController.
* ``before_validate(remainder, params)`` - Called before performing validation
* ``before_call(remainder, params)`` - Called after valdation, before calling the actual controller method
* ``before_render(remainder, params, output)`` - Called before rendering a controller template, ``output`` is the controller return value
Expand Down

0 comments on commit d529b6e

Please sign in to comment.