Docs: Modernize signal examples to use @connect_via decorator
This commit is contained in:
parent
9cd5aa478a
commit
627a0e20bd
1 changed files with 6 additions and 6 deletions
12
docs/api.rst
12
docs/api.rst
|
|
@ -336,14 +336,14 @@ Signals are provided by the `Blinker`_ library. See :doc:`signals` for an introd
|
|||
|
||||
Example subscriber::
|
||||
|
||||
from flask import template_rendered
|
||||
|
||||
@template_rendered.connect_via(app)
|
||||
def log_template_renders(sender, template, context, **extra):
|
||||
sender.logger.debug('Rendering template "%s" with context %s',
|
||||
template.name or 'string template',
|
||||
context)
|
||||
|
||||
from flask import template_rendered
|
||||
template_rendered.connect(log_template_renders, app)
|
||||
|
||||
.. data:: flask.before_render_template
|
||||
:noindex:
|
||||
|
||||
|
|
@ -370,12 +370,12 @@ Signals are provided by the `Blinker`_ library. See :doc:`signals` for an introd
|
|||
|
||||
Example subscriber::
|
||||
|
||||
from flask import request_started
|
||||
|
||||
@request_started.connect_via(app)
|
||||
def log_request(sender, **extra):
|
||||
sender.logger.debug('Request context is set up')
|
||||
|
||||
from flask import request_started
|
||||
request_started.connect(log_request, app)
|
||||
|
||||
.. data:: request_finished
|
||||
|
||||
This signal is sent right before the response is sent to the client.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue