summaryrefslogtreecommitdiff
path: root/docs/narr/events.rst
diff options
context:
space:
mode:
authorAlexandre Bourget <alexandre.bourget@savoirfairelinux.com>2011-03-24 12:07:09 -0400
committerAlexandre Bourget <alexandre.bourget@savoirfairelinux.com>2011-03-24 12:07:09 -0400
commit95e799d074de2e81914d513b4c331df1e738c00e (patch)
treeb3039037533610d8c86d82bb28f139d8a3777013 /docs/narr/events.rst
parent22d3253a26767501827d86b56db3a9b79bef6c4e (diff)
parentb596e1812627c359908759d7a8d83c339f08e385 (diff)
downloadpyramid-95e799d074de2e81914d513b4c331df1e738c00e.tar.gz
pyramid-95e799d074de2e81914d513b4c331df1e738c00e.tar.bz2
pyramid-95e799d074de2e81914d513b4c331df1e738c00e.zip
Merge remote branch 'source/master'
Conflicts: docs/narr/hooks.rst
Diffstat (limited to 'docs/narr/events.rst')
-rw-r--r--docs/narr/events.rst64
1 files changed, 31 insertions, 33 deletions
diff --git a/docs/narr/events.rst b/docs/narr/events.rst
index 06b30883f..929208083 100644
--- a/docs/narr/events.rst
+++ b/docs/narr/events.rst
@@ -38,52 +38,50 @@ 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:
-
- from pyramid.events import NewRequest
+.. code-block:: python
+ :linenos:
- from subscribers import mysubscriber
+ from pyramid.events import NewRequest
- # "config" below is assumed to be an instance of a
- # pyramid.config.Configurator object
+ from subscribers import mysubscriber
- config.add_subscriber(mysubscriber, NewRequest)
+ # "config" below is assumed to be an instance of a
+ # pyramid.config.Configurator object
- 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.
+ config.add_subscriber(mysubscriber, NewRequest)
-.. topic:: Configuring an Event Listener Using a Decorator
+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.
- You can configure a subscriber function to be called for some event
- type via the :func:`pyramid.events.subscriber` function.
+Configuring an Event Listener Using a Decorator
+-----------------------------------------------
- .. code-block:: python
- :linenos:
+You can configure a subscriber function to be called for some event
+type via the :func:`pyramid.events.subscriber` function.
- from pyramid.events import NewRequest
- from pyramid.events import subscriber
+.. code-block:: python
+ :linenos:
- @subscriber(NewRequest)
- def mysubscriber(event):
- event.request.foo = 1
+ from pyramid.events import NewRequest
+ from pyramid.events import subscriber
- 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.
+ @subscriber(NewRequest)
+ def mysubscriber(event):
+ event.request.foo = 1
-.. note:: You can also configure an event listener via ZCML. See
- :ref:`zcml_event_listener`.
+When the :func:`~pyramid.events.subscriber` decorator is used a
+:term:`scan` must be performed against the package containing the
+decorated function for the decorator to have any effect.
Either of the above registration examples implies that every time the
:app:`Pyramid` framework emits an event object that supplies an