Docs: Modernize signal examples to use @connect_via decorator

This commit is contained in:
Mervan Palmér 2026-05-19 15:59:06 +02:00
parent 9cd5aa478a
commit 627a0e20bd

View file

@ -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.