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

<!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>Becoming Big &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="API" href="api.html" />
    <link rel="prev" title="Other Servers" href="deploying/others.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="api.html" title="API"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="deploying/others.html" title="Other Servers"
             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="becoming-big">
<span id="becomingbig"></span><h1>Becoming Big<a class="headerlink" href="#becoming-big" title="Permalink to this headline">¶</a></h1>
<p>Your application is becoming more and more complex?  If you suddenly
realize that Flask does things in a way that does not work out for your
application there are ways to deal with that.</p>
<p>Flask is powered by Werkzeug and Jinja2, two libraries that are in use at
a number of large websites out there and all Flask does is bring those
two together.  Being a microframework Flask does not do much more than
combining existing libraries - there is not a lot of code involved.
What that means for large applications is that it&#8217;s very easy to take the
code from Flask and put it into a new module within the applications and
expand on that.</p>
<p>Flask is designed to be extended and modified in a couple of different
ways:</p>
<ul class="simple">
<li>Flask extensions.  For a lot of reusable functionality you can create
extensions.  For extensions a number of hooks exist throughout Flask
with signals and callback functions.</li>
<li>Subclassing.  The majority of functionality can be changed by creating
a new subclass of the <a class="reference internal" href="api.html#flask.Flask" title="flask.Flask"><tt class="xref py py-class docutils literal"><span class="pre">Flask</span></tt></a> class and overriding
methods provided for this exact purpose.</li>
<li>Forking.  If nothing else works out you can just take the Flask
codebase at a given point and copy/paste it into your application
and change it.  Flask is designed with that in mind and makes this
incredible easy.  You just have to take the package and copy it
into your application&#8217;s code and rename it (for example to
<cite>framework</cite>).  Then you can start modifying the code in there.</li>
</ul>
<div class="section" id="why-consider-forking">
<h2>Why consider Forking?<a class="headerlink" href="#why-consider-forking" title="Permalink to this headline">¶</a></h2>
<p>The majority of code of Flask is within Werkzeug and Jinja2.  These
libraries do the majority of the work.  Flask is just the paste that glues
those together.  For every project there is the point where the underlying
framework gets in the way (due to assumptions the original developers
had).  This is natural because if this would not be the case, the
framework would be a very complex system to begin with which causes a
steep learning curve and a lot of user frustration.</p>
<p>This is not unique to Flask.  Many people use patched and modified
versions of their framework to counter shortcomings.  This idea is also
reflected in the license of Flask.  You don&#8217;t have to contribute any
changes back if you decide to modify the framework.</p>
<p>The downside of forking is of course that Flask extensions will most
likely break because the new framework has a different import name.
Furthermore integrating upstream changes can be a complex process,
depending on the number of changes.  Because of that, forking should be
the very last resort.</p>
</div>
<div class="section" id="scaling-like-a-pro">
<h2>Scaling like a Pro<a class="headerlink" href="#scaling-like-a-pro" title="Permalink to this headline">¶</a></h2>
<p>For many web applications the complexity of the code is less an issue than
the scaling for the number of users or data entries expected.  Flask by
itself is only limited in terms of scaling by your application code, the
data store you want to use and the Python implementation and webserver you
are running on.</p>
<p>Scaling well means for example that if you double the amount of servers
you get about twice the performance.  Scaling bad means that if you add a
new server the application won&#8217;t perform any better or would not even
support a second server.</p>
<p>There is only one limiting factor regarding scaling in Flask which are
the context local proxies.  They depend on context which in Flask is
defined as being either a thread, process or greenlet.  If your server
uses some kind of concurrency that is not based on threads or greenlets,
Flask will no longer be able to support these global proxies.  However the
majority of servers are using either threads, greenlets or separate
processes to achieve concurrency which are all methods well supported by
the underlying Werkzeug library.</p>
</div>
<div class="section" id="dialogue-with-the-community">
<h2>Dialogue with the Community<a class="headerlink" href="#dialogue-with-the-community" title="Permalink to this headline">¶</a></h2>
<p>The Flask developers are very interested to keep everybody happy, so as
soon as you find an obstacle in your way, caused by Flask, don&#8217;t hesitate
to contact the developers on the mailinglist or IRC channel.  The best way
for the Flask and Flask-extension developers to improve it for larger
applications is getting feedback from users.</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="#">Becoming Big</a><ul>
<li><a class="reference internal" href="#why-consider-forking">Why consider Forking?</a></li>
<li><a class="reference internal" href="#scaling-like-a-pro">Scaling like a Pro</a></li>
<li><a class="reference internal" href="#dialogue-with-the-community">Dialogue with the Community</a></li>
</ul>
</li>
</ul>
<h3>Related Topics</h3>
<ul>
  <li><a href="index.html">Documentation overview</a><ul>
      <li>Previous: <a href="deploying/others.html" title="previous chapter">Other Servers</a></li>
      <li>Next: <a href="api.html" title="next chapter">API</a></li>
  </ul></li>
</ul>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/becomingbig.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>