Skip to content
Myr

Documented blinker 1.1 changes

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

authored by Armin Ronacher · committed by Armin Ronacher · parent c5b1755 · Browse files · 1 file+21 added−4 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+21 added−4 removed

  • other:+21 added−4 removed

1 file+21 added−4 removed

modified:docs/signals.rst+21 added-4 removed
77 unmodified lines
78variable. Whenever a template is rendered, the template object as well as79context are appended to it.8081Additionally there is a convenient helper method82(:meth:`~blinker.base.Signal.temporarily_connected_to`). that allows you83to temporarily subscribe a function to a signal with is a context manager84on its own which simplifies the example above::82(:meth:`~blinker.base.Signal.connected_to`). that allows you to83temporarily subscribe a function to a signal with is a context manager on84its own which simplifies the example above::8586 from flask import template_rendered8788 def captured_templates(app):89 recorded = []90 def record(template, context):91 recorded.append((template, context))92 return template_rendered.temporarily_connected_to(record, app)92 return template_rendered.connected_to(record, app)9394.. admonition:: Blinker API Changes9596 The :meth:`~blinker.base.Signal.connected_to` method arrived in Blinker97 with version 1.1.9899Creating Signals100----------------101102If you want to use signals in your own application, you can use the
42 unmodified lines
145 ``current_app._get_current_object()`` instead. The reason for this is146 that :data:`~flask.current_app` is a proxy and not the real application147 object.148149Decorator Based Signal Subscriptions150------------------------------------151152With Blinker 1.1 you can also easily subscribe to signals by using the new153:meth:`~blinker.base.NamedSignal.connect_via` decorator::154155 from flask import template_rendered156157 @template_rendered.connect_via(app)158 def when_template_rendered(template, context):159 print 'Template %s is rendered with %s' % (template.name, context)160161Core Signals162------------163164.. when modifying this list, also update the one in api.rst
68 unmodified lines