Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/studio/static/doc/flask-docs/signals.html
blob: 77250d57302dd505f475fd42e94a01737aa6c5e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Signals &mdash; Flask 0.8 documentation</title>
    
    <link rel="stylesheet" href="_static/flasky.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '0.8',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="Flask 0.8 documentation" href="index.html" />
    <link rel="next" title="Pluggable Views" href="views.html" />
    <link rel="prev" title="Configuration Handling" href="config.html" />
   
  
  <link rel="apple-touch-icon" href="_static/touch-icon.png" />
  
  <link media="only screen and (max-device-width: 480px)" href="_static/small_flask.css" type= "text/css" rel="stylesheet" />

  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="views.html" title="Pluggable Views"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="config.html" title="Configuration Handling"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">Flask 0.8 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="signals">
<span id="id1"></span><h1>Signals<a class="headerlink" href="#signals" title="Permalink to this headline">¶</a></h1>
<p class="versionadded">
<span class="versionmodified">New in version 0.6.</span></p>
<p>Starting with Flask 0.6, there is integrated support for signalling in
Flask.  This support is provided by the excellent <a class="reference external" href="http://pypi.python.org/pypi/blinker">blinker</a> library and
will gracefully fall back if it is not available.</p>
<p>What are signals?  Signals help you decouple applications by sending
notifications when actions occur elsewhere in the core framework or
another Flask extensions.  In short, signals allow certain senders to
notify subscribers that something happened.</p>
<p>Flask comes with a couple of signals and other extensions might provide
more.  Also keep in mind that signals are intended to notify subscribers
and should not encourage subscribers to modify data.  You will notice that
there are signals that appear to do the same thing like some of the
builtin decorators do (eg: <a class="reference internal" href="api.html#flask.request_started" title="flask.request_started"><tt class="xref py py-data docutils literal"><span class="pre">request_started</span></tt></a> is very similar
to <a class="reference internal" href="api.html#flask.Flask.before_request" title="flask.Flask.before_request"><tt class="xref py py-meth docutils literal"><span class="pre">before_request()</span></tt></a>).  There are however difference in
how they work.  The core <a class="reference internal" href="api.html#flask.Flask.before_request" title="flask.Flask.before_request"><tt class="xref py py-meth docutils literal"><span class="pre">before_request()</span></tt></a> handler for
example is executed in a specific order and is able to abort the request
early by returning a response.  In contrast all signal handlers are
executed in undefined order and do not modify any data.</p>
<p>The big advantage of signals over handlers is that you can safely
subscribe to them for the split of a second.  These temporary
subscriptions are helpful for unittesting for example.  Say you want to
know what templates were rendered as part of a request: signals allow you
to do exactly that.</p>
<div class="section" id="subscribing-to-signals">
<h2>Subscribing to Signals<a class="headerlink" href="#subscribing-to-signals" title="Permalink to this headline">¶</a></h2>
<p>To subscribe to a signal, you can use the
<a class="reference external" href="http://discorporate.us/projects/Blinker/docs/1.1/api.html#blinker.base.Signal.connect" title="(in Blinker v1.1)"><tt class="xref py py-meth docutils literal"><span class="pre">connect()</span></tt></a> method of a signal.  The first
argument is the function that should be called when the signal is emitted,
the optional second argument specifies a sender.  To unsubscribe from a
signal, you can use the <a class="reference external" href="http://discorporate.us/projects/Blinker/docs/1.1/api.html#blinker.base.Signal.disconnect" title="(in Blinker v1.1)"><tt class="xref py py-meth docutils literal"><span class="pre">disconnect()</span></tt></a> method.</p>
<p>For all core Flask signals, the sender is the application that issued the
signal.  When you subscribe to a signal, be sure to also provide a sender
unless you really want to listen for signals of all applications.  This is
especially true if you are developing an extension.</p>
<p>Here for example a helper context manager that can be used to figure out
in a unittest which templates were rendered and what variables were passed
to the template:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">flask</span> <span class="kn">import</span> <span class="n">template_rendered</span>
<span class="kn">from</span> <span class="nn">contextlib</span> <span class="kn">import</span> <span class="n">contextmanager</span>

<span class="nd">@contextmanager</span>
<span class="k">def</span> <span class="nf">captured_templates</span><span class="p">(</span><span class="n">app</span><span class="p">):</span>
    <span class="n">recorded</span> <span class="o">=</span> <span class="p">[]</span>
    <span class="k">def</span> <span class="nf">record</span><span class="p">(</span><span class="n">sender</span><span class="p">,</span> <span class="n">template</span><span class="p">,</span> <span class="n">context</span><span class="p">):</span>
        <span class="n">recorded</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">template</span><span class="p">,</span> <span class="n">context</span><span class="p">))</span>
    <span class="n">template_rendered</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">record</span><span class="p">,</span> <span class="n">app</span><span class="p">)</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="k">yield</span> <span class="n">recorded</span>
    <span class="k">finally</span><span class="p">:</span>
        <span class="n">template_rendered</span><span class="o">.</span><span class="n">disconnect</span><span class="p">(</span><span class="n">record</span><span class="p">,</span> <span class="n">app</span><span class="p">)</span>
</pre></div>
</div>
<p>This can now easily be paired with a test client:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">with</span> <span class="n">captured_templates</span><span class="p">(</span><span class="n">app</span><span class="p">)</span> <span class="k">as</span> <span class="n">templates</span><span class="p">:</span>
    <span class="n">rv</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">test_client</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">&#39;/&#39;</span><span class="p">)</span>
    <span class="k">assert</span> <span class="n">rv</span><span class="o">.</span><span class="n">status_code</span> <span class="o">==</span> <span class="mi">200</span>
    <span class="k">assert</span> <span class="nb">len</span><span class="p">(</span><span class="n">templates</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span>
    <span class="n">template</span><span class="p">,</span> <span class="n">context</span> <span class="o">=</span> <span class="n">templates</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
    <span class="k">assert</span> <span class="n">template</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s">&#39;index.html&#39;</span>
    <span class="k">assert</span> <span class="nb">len</span><span class="p">(</span><span class="n">context</span><span class="p">[</span><span class="s">&#39;items&#39;</span><span class="p">])</span> <span class="o">==</span> <span class="mi">10</span>
</pre></div>
</div>
<p>All the template rendering in the code issued by the application <cite>app</cite>
in the body of the <cite>with</cite> block will now be recorded in the <cite>templates</cite>
variable.  Whenever a template is rendered, the template object as well as
context are appended to it.</p>
<p>Additionally there is a convenient helper method
(<a class="reference external" href="http://discorporate.us/projects/Blinker/docs/1.1/api.html#blinker.base.Signal.connected_to" title="(in Blinker v1.1)"><tt class="xref py py-meth docutils literal"><span class="pre">connected_to()</span></tt></a>).  that allows you to
temporarily subscribe a function to a signal with is a context manager on
its own.  Because the return value of the context manager cannot be
specified that way one has to pass the list in as argument:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">flask</span> <span class="kn">import</span> <span class="n">template_rendered</span>

<span class="k">def</span> <span class="nf">captured_templates</span><span class="p">(</span><span class="n">app</span><span class="p">,</span> <span class="n">recorded</span><span class="p">):</span>
    <span class="k">def</span> <span class="nf">record</span><span class="p">(</span><span class="n">sender</span><span class="p">,</span> <span class="n">template</span><span class="p">,</span> <span class="n">context</span><span class="p">):</span>
        <span class="n">recorded</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">template</span><span class="p">,</span> <span class="n">context</span><span class="p">))</span>
    <span class="k">return</span> <span class="n">template_rendered</span><span class="o">.</span><span class="n">connected_to</span><span class="p">(</span><span class="n">record</span><span class="p">,</span> <span class="n">app</span><span class="p">)</span>
</pre></div>
</div>
<p>The example above would then look like this:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">templates</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">with</span> <span class="n">captured_templates</span><span class="p">(</span><span class="n">app</span><span class="p">,</span> <span class="n">templates</span><span class="p">):</span>
    <span class="o">...</span>
    <span class="n">template</span><span class="p">,</span> <span class="n">context</span> <span class="o">=</span> <span class="n">templates</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
</pre></div>
</div>
<div class="admonition-blinker-api-changes admonition ">
<p class="first admonition-title">Blinker API Changes</p>
<p class="last">The <a class="reference external" href="http://discorporate.us/projects/Blinker/docs/1.1/api.html#blinker.base.Signal.connected_to" title="(in Blinker v1.1)"><tt class="xref py py-meth docutils literal"><span class="pre">connected_to()</span></tt></a> method arrived in Blinker
with version 1.1.</p>
</div>
</div>
<div class="section" id="creating-signals">
<h2>Creating Signals<a class="headerlink" href="#creating-signals" title="Permalink to this headline">¶</a></h2>
<p>If you want to use signals in your own application, you can use the
blinker library directly.  The most common use case are named signals in a
custom <a class="reference external" href="http://discorporate.us/projects/Blinker/docs/1.1/api.html#blinker.base.Namespace" title="(in Blinker v1.1)"><tt class="xref py py-class docutils literal"><span class="pre">Namespace</span></tt></a>..  This is what is recommended
most of the time:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">blinker</span> <span class="kn">import</span> <span class="n">Namespace</span>
<span class="n">my_signals</span> <span class="o">=</span> <span class="n">Namespace</span><span class="p">()</span>
</pre></div>
</div>
<p>Now you can create new signals like this:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">model_saved</span> <span class="o">=</span> <span class="n">my_signals</span><span class="o">.</span><span class="n">signal</span><span class="p">(</span><span class="s">&#39;model-saved&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>The name for the signal here makes it unique and also simplifies
debugging.  You can access the name of the signal with the
<a class="reference external" href="http://discorporate.us/projects/Blinker/docs/1.1/api.html#blinker.base.NamedSignal.name" title="(in Blinker v1.1)"><tt class="xref py py-attr docutils literal"><span class="pre">name</span></tt></a> attribute.</p>
<div class="admonition-for-extension-developers admonition ">
<p class="first admonition-title">For Extension Developers</p>
<p class="last">If you are writing a Flask extension and you want to gracefully degrade for
missing blinker installations, you can do so by using the
<a class="reference internal" href="api.html#flask.signals.Namespace" title="flask.signals.Namespace"><tt class="xref py py-class docutils literal"><span class="pre">flask.signals.Namespace</span></tt></a> class.</p>
</div>
</div>
<div class="section" id="sending-signals">
<h2>Sending Signals<a class="headerlink" href="#sending-signals" title="Permalink to this headline">¶</a></h2>
<p>If you want to emit a signal, you can do so by calling the
<a class="reference external" href="http://discorporate.us/projects/Blinker/docs/1.1/api.html#blinker.base.Signal.send" title="(in Blinker v1.1)"><tt class="xref py py-meth docutils literal"><span class="pre">send()</span></tt></a> method.  It accepts a sender as first
argument and optionally some keyword arguments that are forwarded to the
signal subscribers:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">Model</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="o">...</span>

    <span class="k">def</span> <span class="nf">save</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">model_saved</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
</pre></div>
</div>
<p>Try to always pick a good sender.  If you have a class that is emitting a
signal, pass <cite>self</cite> as sender.  If you emitting a signal from a random
function, you can pass <tt class="docutils literal"><span class="pre">current_app._get_current_object()</span></tt> as sender.</p>
<div class="admonition-passing-proxies-as-senders admonition ">
<p class="first admonition-title">Passing Proxies as Senders</p>
<p class="last">Never pass <a class="reference internal" href="api.html#flask.current_app" title="flask.current_app"><tt class="xref py py-data docutils literal"><span class="pre">current_app</span></tt></a> as sender to a signal.  Use
<tt class="docutils literal"><span class="pre">current_app._get_current_object()</span></tt> instead.  The reason for this is
that <a class="reference internal" href="api.html#flask.current_app" title="flask.current_app"><tt class="xref py py-data docutils literal"><span class="pre">current_app</span></tt></a> is a proxy and not the real application
object.</p>
</div>
</div>
<div class="section" id="decorator-based-signal-subscriptions">
<h2>Decorator Based Signal Subscriptions<a class="headerlink" href="#decorator-based-signal-subscriptions" title="Permalink to this headline">¶</a></h2>
<p>With Blinker 1.1 you can also easily subscribe to signals by using the new
<tt class="xref py py-meth docutils literal"><span class="pre">connect_via()</span></tt> decorator:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">flask</span> <span class="kn">import</span> <span class="n">template_rendered</span>

<span class="nd">@template_rendered.connect_via</span><span class="p">(</span><span class="n">app</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">when_template_rendered</span><span class="p">(</span><span class="n">sender</span><span class="p">,</span> <span class="n">template</span><span class="p">,</span> <span class="n">context</span><span class="p">):</span>
    <span class="k">print</span> <span class="s">&#39;Template </span><span class="si">%s</span><span class="s"> is rendered with </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">template</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">context</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="core-signals">
<h2>Core Signals<a class="headerlink" href="#core-signals" title="Permalink to this headline">¶</a></h2>
<p>The following signals exist in Flask:</p>
<dl class="data">
<dt>
<tt class="descclassname">flask.</tt><tt class="descname">template_rendered</tt></dt>
<dd><p>This signal is sent when a template was successfully rendered.  The
signal is invoked with the instance of the template as <cite>template</cite>
and the context as dictionary (named <cite>context</cite>).</p>
<p>Example subscriber:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">log_template_renders</span><span class="p">(</span><span class="n">sender</span><span class="p">,</span> <span class="n">template</span><span class="p">,</span> <span class="n">context</span><span class="p">):</span>
    <span class="n">sender</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&#39;Rendering template &quot;</span><span class="si">%s</span><span class="s">&quot; with context </span><span class="si">%s</span><span class="s">&#39;</span><span class="p">,</span>
                        <span class="n">template</span><span class="o">.</span><span class="n">name</span> <span class="ow">or</span> <span class="s">&#39;string template&#39;</span><span class="p">,</span>
                        <span class="n">context</span><span class="p">)</span>

<span class="kn">from</span> <span class="nn">flask</span> <span class="kn">import</span> <span class="n">template_rendered</span>
<span class="n">template_rendered</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">log_template_renders</span><span class="p">,</span> <span class="n">app</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="data">
<dt>
<tt class="descclassname">flask.</tt><tt class="descname">request_started</tt></dt>
<dd><p>This signal is sent before any request processing started but when the
request context was set up.  Because the request context is already
bound, the subscriber can access the request with the standard global
proxies such as <a class="reference internal" href="api.html#flask.request" title="flask.request"><tt class="xref py py-class docutils literal"><span class="pre">request</span></tt></a>.</p>
<p>Example subscriber:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">log_request</span><span class="p">(</span><span class="n">sender</span><span class="p">):</span>
    <span class="n">sender</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&#39;Request context is set up&#39;</span><span class="p">)</span>

<span class="kn">from</span> <span class="nn">flask</span> <span class="kn">import</span> <span class="n">request_started</span>
<span class="n">request_started</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">log_request</span><span class="p">,</span> <span class="n">app</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="data">
<dt>
<tt class="descclassname">flask.</tt><tt class="descname">request_finished</tt></dt>
<dd><p>This signal is sent right before the response is sent to the client.
It is passed the response to be sent named <cite>response</cite>.</p>
<p>Example subscriber:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">log_response</span><span class="p">(</span><span class="n">sender</span><span class="p">,</span> <span class="n">response</span><span class="p">):</span>
    <span class="n">sender</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&#39;Request context is about to close down.  &#39;</span>
                        <span class="s">&#39;Response: </span><span class="si">%s</span><span class="s">&#39;</span><span class="p">,</span> <span class="n">response</span><span class="p">)</span>

<span class="kn">from</span> <span class="nn">flask</span> <span class="kn">import</span> <span class="n">request_finished</span>
<span class="n">request_finished</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">log_response</span><span class="p">,</span> <span class="n">app</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="data">
<dt>
<tt class="descclassname">flask.</tt><tt class="descname">got_request_exception</tt></dt>
<dd><p>This signal is sent when an exception happens during request processing.
It is sent <em>before</em> the standard exception handling kicks in and even
in debug mode, where no exception handling happens.  The exception
itself is passed to the subscriber as <cite>exception</cite>.</p>
<p>Example subscriber:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">log_exception</span><span class="p">(</span><span class="n">sender</span><span class="p">,</span> <span class="n">exception</span><span class="p">):</span>
    <span class="n">sender</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&#39;Got exception during processing: </span><span class="si">%s</span><span class="s">&#39;</span><span class="p">,</span> <span class="n">exception</span><span class="p">)</span>

<span class="kn">from</span> <span class="nn">flask</span> <span class="kn">import</span> <span class="n">got_request_exception</span>
<span class="n">got_request_exception</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">log_exception</span><span class="p">,</span> <span class="n">app</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="data">
<dt>
<tt class="descclassname">flask.</tt><tt class="descname">request_tearing_down</tt></dt>
<dd><p>This signal is sent when the request is tearing down.  This is always
called, even if an exception is caused.  Currently functions listening
to this signal are called after the regular teardown handlers, but this
is not something you can rely on.</p>
<p>Example subscriber:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">close_db_connection</span><span class="p">(</span><span class="n">sender</span><span class="p">):</span>
    <span class="n">session</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>

<span class="kn">from</span> <span class="nn">flask</span> <span class="kn">import</span> <span class="n">request_tearing_down</span>
<span class="n">request_tearing_down</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">close_db_connection</span><span class="p">,</span> <span class="n">app</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper"><p class="logo"><a href="index.html">
  <img class="logo" src="_static/flask.png" alt="Logo"/>
</a></p>
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Signals</a><ul>
<li><a class="reference internal" href="#subscribing-to-signals">Subscribing to Signals</a></li>
<li><a class="reference internal" href="#creating-signals">Creating Signals</a></li>
<li><a class="reference internal" href="#sending-signals">Sending Signals</a></li>
<li><a class="reference internal" href="#decorator-based-signal-subscriptions">Decorator Based Signal Subscriptions</a></li>
<li><a class="reference internal" href="#core-signals">Core Signals</a></li>
</ul>
</li>
</ul>
<h3>Related Topics</h3>
<ul>
  <li><a href="index.html">Documentation overview</a><ul>
      <li>Previous: <a href="config.html" title="previous chapter">Configuration Handling</a></li>
      <li>Next: <a href="views.html" title="next chapter">Pluggable Views</a></li>
  </ul></li>
</ul>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/signals.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy; Copyright 2010, Armin Ronacher.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
    </div>
  </body>
</html>