Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/studio/static/doc/flask-docs/extensions.html
blob: d5ee4a7e89604e55b2637913d4c463a2c86a2e76 (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

<!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>Flask Extensions &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="Working with the Shell" href="shell.html" />
    <link rel="prev" title="Modular Applications with Blueprints" href="blueprints.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="shell.html" title="Working with the Shell"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="blueprints.html" title="Modular Applications with Blueprints"
             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="flask-extensions">
<h1>Flask Extensions<a class="headerlink" href="#flask-extensions" title="Permalink to this headline">¶</a></h1>
<p>Flask extensions extend the functionality of Flask in various different
ways.  For instance they add support for databases and other common tasks.</p>
<div class="section" id="finding-extensions">
<h2>Finding Extensions<a class="headerlink" href="#finding-extensions" title="Permalink to this headline">¶</a></h2>
<p>Flask extensions are listed on the <a class="reference external" href="http://flask.pocoo.org/extensions/">Flask Extension Registry</a> and can be
downloaded with <tt class="docutils literal"><span class="pre">easy_install</span></tt> or <tt class="docutils literal"><span class="pre">pip</span></tt>.  If you add a Flask extension
as dependency to your <tt class="docutils literal"><span class="pre">requirements.rst</span></tt> or <tt class="docutils literal"><span class="pre">setup.py</span></tt> file they are
usually installed with a simple command or when your application installs.</p>
</div>
<div class="section" id="using-extensions">
<h2>Using Extensions<a class="headerlink" href="#using-extensions" title="Permalink to this headline">¶</a></h2>
<p>Extensions typically have documentation that goes along that shows how to
use it.  There are no general rules in how extensions are supposed to
behave but they are imported from common locations.  If you have an
extension called <tt class="docutils literal"><span class="pre">Flask-Foo</span></tt> or <tt class="docutils literal"><span class="pre">Foo-Flask</span></tt> it will be always
importable from <tt class="docutils literal"><span class="pre">flask.ext.foo</span></tt>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">flask.ext</span> <span class="kn">import</span> <span class="n">foo</span>
</pre></div>
</div>
</div>
<div class="section" id="flask-before-0-8">
<h2>Flask Before 0.8<a class="headerlink" href="#flask-before-0-8" title="Permalink to this headline">¶</a></h2>
<p>If you are using Flask 0.7 or earlier the <tt class="xref py py-data docutils literal"><span class="pre">flask.ext</span></tt> package will not
exist, instead you have to import from <tt class="docutils literal"><span class="pre">flaskext.foo</span></tt> or <tt class="docutils literal"><span class="pre">flask_foo</span></tt>
depending on how the extension is distributed.  If you want to develop an
application that supports Flask 0.7 or earlier you should still import
from the <tt class="xref py py-data docutils literal"><span class="pre">flask.ext</span></tt> package.  We provide you with a compatibility
module that provides this package for older versions of Flask.  You can
download it from github: <a class="reference external" href="https://github.com/mitsuhiko/flask/raw/master/scripts/flaskext_compat.py">flaskext_compat.py</a></p>
<p>And here is how you can use it:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">flaskext_compat</span>
<span class="n">flaskext_compat</span><span class="o">.</span><span class="n">activate</span><span class="p">()</span>

<span class="kn">from</span> <span class="nn">flask.ext</span> <span class="kn">import</span> <span class="n">foo</span>
</pre></div>
</div>
<p>Once the <tt class="docutils literal"><span class="pre">flaskext_compat</span></tt> module is activated the <tt class="xref py py-data docutils literal"><span class="pre">flask.ext</span></tt> will
exist and you can start importing from there.</p>
</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="#">Flask Extensions</a><ul>
<li><a class="reference internal" href="#finding-extensions">Finding Extensions</a></li>
<li><a class="reference internal" href="#using-extensions">Using Extensions</a></li>
<li><a class="reference internal" href="#flask-before-0-8">Flask Before 0.8</a></li>
</ul>
</li>
</ul>
<h3>Related Topics</h3>
<ul>
  <li><a href="index.html">Documentation overview</a><ul>
      <li>Previous: <a href="blueprints.html" title="previous chapter">Modular Applications with Blueprints</a></li>
      <li>Next: <a href="shell.html" title="next chapter">Working with the Shell</a></li>
  </ul></li>
</ul>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/extensions.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>