Subscribe to signals with extra kwargs in the docs
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 ebd7468 · 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
Provenance
- Commit
230e136- Tree
74747a4- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
ebd7468
1 file changed+8 added−8 removed
modified:docs/signals.rst+8 added-8 removed
84 unmodified lines85 specified that way one has to pass the list in as argument::86 87 from flask import template_rendered88 89- def captured_templates(app, recorded):89+ def captured_templates(app, recorded, **extra):90 def record(sender, template, context):91 recorded.append((template, context))92 return template_rendered.connected_to(record, app)93 94 The example above would then look like this::95 96 templates = []97- with captured_templates(app, templates):97+ with captured_templates(app, templates, **extra):98 ...99 template, context = templates[0]100 101 .. admonition:: Blinker API Changes59 unmodified lines161 162 from flask import template_rendered163 164 @template_rendered.connect_via(app)165- def when_template_rendered(sender, template, context):165+ def when_template_rendered(sender, template, context, **extra):166 print 'Template %s is rendered with %s' % (template.name, context)167 168 Core Signals169 ------------10 unmodified lines180 and the context as dictionary (named `context`).181 182 Example subscriber::183 184- def log_template_renders(sender, template, context):184+ def log_template_renders(sender, template, context, **extra):185 sender.logger.debug('Rendering template "%s" with context %s',186 template.name or 'string template',187 context)188 9 unmodified lines198 proxies such as :class:`~flask.request`.199 200 Example subscriber::201 202- def log_request(sender):202+ def log_request(sender, **extra):203 sender.logger.debug('Request context is set up')204 205 from flask import request_started206 request_started.connect(log_request, app)5 unmodified lines212 It is passed the response to be sent named `response`.213 214 Example subscriber::215 216- def log_response(sender, response):216+ def log_response(sender, response, **extra):217 sender.logger.debug('Request context is about to close down. '218 'Response: %s', response)219 220 from flask import request_finished8 unmodified lines229 itself is passed to the subscriber as `exception`.230 231 Example subscriber::232 233- def log_exception(sender, exception):233+ def log_exception(sender, exception, **extra):234 sender.logger.debug('Got exception during processing: %s', exception)235 236 from flask import got_request_exception237 got_request_exception.connect(log_exception, app)7 unmodified lines245 is not something you can rely on.246 247 Example subscriber::248 249- def close_db_connection(sender):249+ def close_db_connection(sender, **extra):250 session.close()251 252 from flask import request_tearing_down253 request_tearing_down.connect(close_db_connection, app)2 unmodified lines