<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hello, everybody!<br>
<br>
I'm reading about <a
href="http://flask.pocoo.org/docs/0.10/extensiondev/">extensions
development</a> and it says:<br>
<blockquote>
<p>As you noticed, <code class="docutils literal"><span
class="pre">init_app</span></code> does not assign <code
class="docutils literal"><span class="pre">app</span></code>
to <code class="docutils literal"><span class="pre">self</span></code>.
This
is intentional! <b>Class based Flask extensions must only store
the
application on the object when the application was passed to
the
constructor.</b> This tells the extension: I am not interested
in using
multiple applications.</p>
<p class="last"><b>When the extension needs to find the current
application and it does
not have a reference to it, it must either use the
</b><b><a class="reference internal"
href="http://flask.pocoo.org/docs/0.10/api/#flask.current_app"
title="flask.current_app"><code class="xref py py-data
docutils literal"><span class="pre">current_app</span></code></a></b>
context local or change the API in a way
that you can pass the application explicitly.</p>
</blockquote>
But <a
href="http://flask.pocoo.org/docs/0.10/extensiondev/#the-extension-code">the
example extension</a>, just uses <tt>flask.current_app</tt>,
without checking whether an application instance was attached to the
extension instance:<br>
<blockquote>
<pre><span class="k">...
def</span> <span class="nf">connect</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="n">sqlite3</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><b><span class="n">current_app</span></b><span class="o">.</span><span class="n">config</span><span class="p">[</span><span class="s1">'SQLITE3_DATABASE'</span><span class="p">])</span>
...
</pre>
</blockquote>
So, where is the truth? What extension should really do - always use
<tt>flask.current_app</tt>, or use it only if application instance
wasn't passed to the constructor?<br>
<pre class="moz-signature" cols="72">--
With kind regards, Andrew Pashkin.
cell phone - +7 (985) 898 57 59
Skype - waves_in_fluids
e-mail - <a class="moz-txt-link-abbreviated" href="mailto:andrew.pashkin@gmx.co.uk">andrew.pashkin@gmx.co.uk</a></pre>
</body>
</html>