Skip to content
Myr

Merge pull request #1349 from jeffwidman/patch-1

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Signals.rst: Grammar and readability fixes

authored by Markus Unterwaditzer · committed by Markus Unterwaditzer · parents 6521c36, ffe0c54 · Browse files · 1 file+8 added−8 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+8 added−8 removed

  • other:+8 added−8 removed

1 file+8 added−8 removed

modified:docs/signals.rst+8 added-8 removed
24 unmodified lines
25early by returning a response. In contrast all signal handlers are26executed in undefined order and do not modify any data.2728The big advantage of signals over handlers is that you can safely29subscribe to them for the split of a second. These temporary29subscribe to them for just a split second. These temporary30subscriptions are helpful for unittesting for example. Say you want to31know what templates were rendered as part of a request: signals allow you32to do exactly that.33
7 unmodified lines
41signal, you can use the :meth:`~blinker.base.Signal.disconnect` method.4243For all core Flask signals, the sender is the application that issued the44signal. When you subscribe to a signal, be sure to also provide a sender45unless you really want to listen for signals of all applications. This is45unless you really want to listen for signals from all applications. This is46especially true if you are developing an extension.4748Here for example a helper context manager that can be used to figure out49in a unittest which templates were rendered and what variables were passed48For example, here is a helper context manager that can be used in a unittest49to determine which templates were rendered and what variables were passed50to the template::5152 from flask import template_rendered53 from contextlib import contextmanager
27 unmodified lines
81variable. Whenever a template is rendered, the template object as well as82context are appended to it.8384Additionally there is a convenient helper method85(:meth:`~blinker.base.Signal.connected_to`). that allows you to85(:meth:`~blinker.base.Signal.connected_to`) that allows you to86temporarily subscribe a function to a signal with a context manager on87its own. Because the return value of the context manager cannot be88specified that way one has to pass the list in as argument::88specified that way, you have to pass the list in as an argument::8990 from flask import template_rendered9192 def captured_templates(app, recorded, **extra):
114 unmodified lines
207208.. data:: flask.request_started209 :noindex:210211 This signal is sent before any request processing started but when the212 request context was set up. Because the request context is already211 This signal is sent when the request context is set up, before212 any request processing happens. Because the request context is already213 bound, the subscriber can access the request with the standard global214 proxies such as :class:`~flask.request`.215216 Example subscriber::
136 unmodified lines