diff options
| author | Chris McDonough <chrism@plope.com> | 2011-01-19 01:37:18 -0500 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2011-01-19 01:37:18 -0500 |
| commit | e3bb4cd9e413e58ec6c7ea7d4682bac329b712dd (patch) | |
| tree | b0c3b4f5dd8a0ec1c01912bfeff769d1329a9c97 /docs/narr/events.rst | |
| parent | 48bccbe4ff7351d823a471005effea1afc06bb4f (diff) | |
| parent | b0240d3d5a39a504d5a5155a23a6d6a431b457ef (diff) | |
| download | pyramid-e3bb4cd9e413e58ec6c7ea7d4682bac329b712dd.tar.gz pyramid-e3bb4cd9e413e58ec6c7ea7d4682bac329b712dd.tar.bz2 pyramid-e3bb4cd9e413e58ec6c7ea7d4682bac329b712dd.zip | |
Merge branch 'caseman-master'
Diffstat (limited to 'docs/narr/events.rst')
| -rw-r--r-- | docs/narr/events.rst | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/docs/narr/events.rst b/docs/narr/events.rst index 6fc3d1424..224eeca16 100644 --- a/docs/narr/events.rst +++ b/docs/narr/events.rst @@ -38,49 +38,51 @@ you'll need to use the need to use the :func:`pyramid.events.subscriber` decorator to decorate a function found via a :term:`scan`. -.. topic:: Configuring an Event Listener Imperatively +Configuring an Event Listener Imperatively +------------------------------------------ - You can imperatively configure a subscriber function to be called - for some event type via the - :meth:`pyramid.config.Configurator.add_subscriber` - method (see also :term:`Configurator`): +You can imperatively configure a subscriber function to be called +for some event type via the +:meth:`pyramid.config.Configurator.add_subscriber` +method (see also :term:`Configurator`): - .. code-block:: python - :linenos: +.. code-block:: python + :linenos: - from pyramid.events import NewRequest + from pyramid.events import NewRequest - from subscribers import mysubscriber + from subscribers import mysubscriber - # "config" below is assumed to be an instance of a - # pyramid.config.Configurator object + # "config" below is assumed to be an instance of a + # pyramid.config.Configurator object - config.add_subscriber(mysubscriber, NewRequest) + config.add_subscriber(mysubscriber, NewRequest) - The first argument to - :meth:`pyramid.config.Configurator.add_subscriber` is the - subscriber function (or a :term:`dotted Python name` which refers - to a subscriber callable); the second argument is the event type. +The first argument to +:meth:`pyramid.config.Configurator.add_subscriber` is the +subscriber function (or a :term:`dotted Python name` which refers +to a subscriber callable); the second argument is the event type. -.. topic:: Configuring an Event Listener Using a Decorator +Configuring an Event Listener Using a Decorator +----------------------------------------------- - You can configure a subscriber function to be called for some event - type via the :func:`pyramid.events.subscriber` function. +You can configure a subscriber function to be called for some event +type via the :func:`pyramid.events.subscriber` function. - .. code-block:: python - :linenos: +.. code-block:: python + :linenos: - from pyramid.events import NewRequest - from pyramid.events import subscriber + from pyramid.events import NewRequest + from pyramid.events import subscriber - @subscriber(NewRequest) - def mysubscriber(event): - event.request.foo = 1 + @subscriber(NewRequest) + def mysubscriber(event): + event.request.foo = 1 - When the :func:`pyramid.subscriber` decorator is used a - :term:`scan` must be performed against the package containing the - decorated function for the decorator to have any effect. See - :func:`pyramid.subscriber` for more information. +When the :func:`pyramid.subscriber` decorator is used a +:term:`scan` must be performed against the package containing the +decorated function for the decorator to have any effect. See +:func:`pyramid.subscriber` for more information. Either of the above registration examples implies that every time the :app:`Pyramid` framework emits an event object that supplies an |
