# Reviewing hg-review

No signoffs yet…

## Files

YnVuZGxlZC9mbGFzay8uZ2l0aWdub3Jl

 0 + .DS_Store 1 + *.pyc 2 + *.pyo 3 + env 4 + env* 5 + dist 6 + *.egg 7 + *.egg-info 8 + _mailinglist 9 + .tox
YnVuZGxlZC9mbGFzay8uZ2l0bW9kdWxlcw==

 0 + [submodule "docs/_themes"] 1 +  path = docs/_themes 2 +  url = git://github.com/mitsuhiko/flask-sphinx-themes.git
YnVuZGxlZC9mbGFzay9BVVRIT1JT

 … skipped 6 lines … 6 - Armin Ronacher  7 8 Patches and Suggestions 9  10 11 + - Adam Zapletal 12 + - Ali Afshar 13 - Chris Edgemon 14 - Chris Grindstaff 15 + - Christopher Grebs 16 - Florent Xicluna 17 - Georg Brandl 18 - Justin Quick 19 - Kenneth Reitz 20 - Marian Sigler 21 + - Matt Campell 22 - Matthew Frazier 23 + - Michael van Tellingen 24 - Ron DuPlain 25 - Sebastien Estienne 26 - Simon Sapin 27 - Stephane Wirtel 28 + - Thomas Schranz 29 - Zhao Xiaohong
YnVuZGxlZC9mbGFzay9DSEFOR0VT

 0 Flask Changelog 1 =============== 2 3 Here you can see the full list of changes between each Flask release. 4 5 + Version 0.7 6 + ----------- 7 + 8 + Release date to be announced, codename to be selected 9 + 10 + - Added :meth:~flask.Flask.make_default_options_response 11 +  which can be used by subclasses to alter the default 12 +  behaviour for OPTIONS responses. 13 + - Unbound locals now raise a proper :exc:RuntimeError instead 14 +  of an :exc:AttributeError. 15 + - Mimetype guessing and etag support based on file objects is now 16 +  deprecated for :func:flask.send_file because it was unreliable. 17 +  Pass filenames instead or attach your own etags and provide a 18 +  proper mimetype by hand. 19 + - Static file handling for modules now requires the name of the 20 +  static folder to be supplied explicitly. The previous autodetection 21 +  was not reliable and caused issues on Google's App Engine. Until 22 +  1.0 the old behaviour will continue to work but issue dependency 23 +  warnings. 24 + - fixed a problem for Flask to run on jython. 25 + - added a PROPAGATE_EXCEPTIONS configuration variable that can be 26 +  used to flip the setting of exception propagation which previously 27 +  was linked to DEBUG alone and is now linked to either DEBUG or 28 +  TESTING. 29 + - Flask no longer internally depends on rules being added through the 30 +  add_url_rule function and can now also accept regular werkzeug 31 +  rules added to the url map. 32 + - Added an endpoint method to the flask application object which 33 +  allows one to register a callback to an arbitrary endpoint with 34 +  a decorator. 35 + 36 + Version 0.6.1 37 + ------------- 38 + 39 + Bugfix release, released on December 31st 2010 40 + 41 + - Fixed an issue where the default OPTIONS response was 42 +  not exposing all valid methods in the Allow header. 43 + - Jinja2 template loading syntax now allows "./" in front of 44 +  a template load path. Previously this caused issues with 45 +  module setups. 46 + - Fixed an issue where the subdomain setting for modules was 47 +  ignored for the static folder. 48 + - Fixed a security problem that allowed clients to download arbitrary files 49 +  if the host server was a windows based operating system and the client 50 +  uses backslashes to escape the directory the files where exposed from. 51 + 52 + Version 0.6 53 + ----------- 54 + 55 + Released on July 27th 2010, codename Whisky 56 + 57 + - after request functions are now called in reverse order of 58 +  registration. 59 + - OPTIONS is now automatically implemented by Flask unless the 60 +  application explicitly adds 'OPTIONS' as method to the URL rule. 61 +  In this case no automatic OPTIONS handling kicks in. 62 + - static rules are now even in place if there is no static folder 63 +  for the module. This was implemented to aid GAE which will 64 +  remove the static folder if it's part of a mapping in the .yml 65 +  file. 66 + - the :attr:~flask.Flask.config is now available in the templates 67 +  as config. 68 + - context processors will no longer override values passed directly 69 +  to the render function. 70 + - added the ability to limit the incoming request data with the 71 +  new MAX_CONTENT_LENGTH configuration value. 72 + - the endpoint for the :meth:flask.Module.add_url_rule method 73 +  is now optional to be consistent with the function of the 74 +  same name on the application object. 75 + - added a :func:flask.make_response function that simplifies 76 +  creating response object instances in views. 77 + - added signalling support based on blinker. This feature is currently 78 +  optional and supposed to be used by extensions and applications. If 79 +  you want to use it, make sure to have blinker_ installed. 80 + - refactored the way URL adapters are created. This process is now 81 +  fully customizable with the :meth:~flask.Flask.create_url_adapter 82 +  method. 83 + - modules can now register for a subdomain instead of just an URL 84 +  prefix. This makes it possible to bind a whole module to a 85 +  configurable subdomain. 86 + 87 + .. _blinker: http://pypi.python.org/pypi/blinker 88 + 89 + Version 0.5.2 90 + ------------- 91 + 92 + Bugfix Release, released on July 15th 2010 93 + 94 + - fixed another issue with loading templates from directories when 95 +  modules were used. 96 + 97 + Version 0.5.1 98 + ------------- 99 + 100 + Bugfix Release, released on July 6th 2010 101 + 102 + - fixes an issue with template loading from directories when modules 103 +  where used. 104 + 105 + Version 0.5 106 + ----------- 107 + 108 + Released on July 6th 2010, codename Calvados 109 + 110 + - fixed a bug with subdomains that was caused by the inability to 111 +  specify the server name. The server name can now be set with 112 +  the SERVER_NAME config key. This key is now also used to set 113 +  the session cookie cross-subdomain wide. 114 + - autoescaping is no longer active for all templates. Instead it 115 +  is only active for .html, .htm, .xml and .xhtml. 116 +  Inside templates this behaviour can be changed with the 117 +  autoescape tag. 118 + - refactored Flask internally. It now consists of more than a 119 +  single file. 120 + - :func:flask.send_file now emits etags and has the ability to 121 +  do conditional responses builtin. 122 + - (temporarily) dropped support for zipped applications. This was a 123 +  rarely used feature and led to some confusing behaviour. 124 + - added support for per-package template and static-file directories. 125 + - removed support for create_jinja_loader which is no longer used 126 +  in 0.5 due to the improved module support. 127 + - added a helper function to expose files from any directory. 128 + 129 Version 0.4 130 ----------- 131 132 - Release date to be announced, codename to be selected. 133 + Released on June 18th 2010, codename Rakia 134 135 - added the ability to register application wide error handlers 136  from modules. 137 - :meth:~flask.Flask.after_request handlers are now also invoked 138  if the request dies with an exception and an error handling page … skipped 3 lines … 141  for a little longer. This can also be used to trigger custom 142  requests that do not pop the request stack for testing. 143 - because the Python standard library caches loggers, the name of 144  the logger is configurable now to better support unittests. 145 - added TESTING switch that can activate unittesting helpers. 146 + - the logger switches to DEBUG mode now if debug is enabled. 147 148 Version 0.3.1 149 ------------- 150 151 - Bugfix release, released May 28th 152 + Bugfix release, released on May 28th 2010 153 154 - fixed a error reporting bug with :meth:flask.Config.from_envvar 155 - removed some unused code from flask 156 - release does no longer include development leftover files (.git 157  folder for themes, built documentation in zip and pdf file and 158  some .pyc files) 159 160 Version 0.3 161 ----------- 162 163 - Released on May 28th, codename Schnaps 164 + Released on May 28th 2010, codename Schnaps 165 166 - added support for categories for flashed messages. 167 - the application now configures a :class:logging.Handler and will 168  log request handling exceptions to that logger when not in debug 169  mode. This makes it possible to receive mails on server errors … skipped 6 lines … 175 - added support for configurations. 176 177 Version 0.2 178 ----------- 179 180 - Released on May 12th, codename J��germeister 181 + Released on May 12th 2010, codename J��germeister 182 183 - various bugfixes 184 - integrated JSON support 185 - added :func:~flask.get_template_attribute helper function. 186 - :meth:~flask.Flask.add_url_rule can now also register a … skipped 15 lines …
YnVuZGxlZC9mbGFzay9MSUNFTlNF

 0 Copyright (c) 2010 by Armin Ronacher and contributors. See AUTHORS 1 for more details. 2 3 Some rights reserved. 4 5 - Redistribution and use in source and binary forms, with or without 6 - modification, are permitted provided that the following conditions are 7 - met: 8 + Redistribution and use in source and binary forms of the software as well 9 + as documentation, with or without modification, are permitted provided 10 + that the following conditions are met: 11 12 * Redistributions of source code must retain the above copyright 13  notice, this list of conditions and the following disclaimer. 14 15 * Redistributions in binary form must reproduce the above … skipped 4 lines … 19 20 * The names of the contributors may not be used to endorse or 21  promote products derived from this software without specific 22  prior written permission. 23 24 - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 + THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE COPYRIGHT HOLDERS AND 36 + CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 37 + NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 38 + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 39 + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 40 + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 41 + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 42 + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 43 + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 44 + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 45 + SOFTWARE AND DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 46 + DAMAGE.
YnVuZGxlZC9mbGFzay9NQU5JRkVTVC5pbg==

 0 include Makefile CHANGES LICENSE AUTHORS 1 + recursive-include artwork * 2 recursive-include tests * 3 recursive-include examples * 4 recursive-include docs * 5 recursive-exclude docs *.pyc 6 recursive-exclude docs *.pyo 7 + recursive-exclude tests *.pyc 8 + recursive-exclude tests *.pyo 9 recursive-exclude examples *.pyc 10 recursive-exclude examples *.pyo 11 prune docs/_build 12 prune docs/_themes/.git
YnVuZGxlZC9mbGFzay9NYWtlZmlsZQ==

 0 - .PHONY: clean-pyc test upload-docs 1 + .PHONY: clean-pyc ext-test test upload-docs docs audit 2 3 all: clean-pyc test 4 5 test: 6  python setup.py test 7 8 + audit: 9 +  python setup.py audit 10 + 11 + tox-test: 12 +  PYTHONDONTWRITEBYTECODE= tox 13 + 14 + ext-test: 15 +  python tests/flaskext_test.py --browse 16 + 17 release: 18  python setup.py release sdist upload 19 20 clean-pyc: 21  find . -name '*.pyc' -exec rm -f {} + … skipped 6 lines … 27  $(MAKE) -C docs/_build/latex all-pdf 28  cd docs/_build/; mv html flask-docs; zip -r flask-docs.zip flask-docs; mv flask-docs html 29  scp -r docs/_build/dirhtml/* pocoo.org:/var/www/flask.pocoo.org/docs/ 30  scp -r docs/_build/latex/Flask.pdf pocoo.org:/var/www/flask.pocoo.org/docs/flask-docs.pdf 31  scp -r docs/_build/flask-docs.zip pocoo.org:/var/www/flask.pocoo.org/docs/ 32 + 33 + docs: 34 + $(MAKE) -C docs html
YnVuZGxlZC9mbGFzay9hcnR3b3JrL0xJQ0VOU0U=

 0 + Copyright (c) 2010 by Armin Ronacher. 1 + 2 + Some rights reserved. 3 + 4 + This logo or a modified version may be used by anyone to refer to the 5 + Flask project, but does not indicate endorsement by the project. 6 + 7 + Redistribution and use in source (the SVG file) and binary forms (rendered 8 + PNG files etc.) of the image, with or without modification, are permitted 9 + provided that the following conditions are met: 10 + 11 + * Redistributions of source code must retain the above copyright 12 +  notice and this list of conditions. 13 + 14 + * The names of the contributors to the Flask software (see AUTHORS) may 15 +  not be used to endorse or promote products derived from this software 16 +  without specific prior written permission. 17 + 18 + Note: we would appreciate that you make the image a link to 19 + http://flask.pocoo.org/ if you use it on a web page.
YnVuZGxlZC9mbGFzay9hcnR3b3JrL2xvZ28tZnVsbC5zdmc=

 0 +  1 +  2 + 3 +  17 +   19 +   26 +   33 +   40 +   47 +   54 +   61 +   68 +   75 +   82 +   89 +   96 +   103 +   104 +   122 +   124 +   125 +   127 +  image/svg+xml 128 +   130 +   131 +   132 +   133 +   134 +   139 +   143 +   146 +   150 +   154 +   158 +   162 +   166 +   167 +   171 +   175 +   179 +   183 +   187 +   191 +   195 +   199 +   203 +   207 +   211 +   215 +   219 +   223 +   227 +   231 +   235 +   239 +   243 +   247 +   251 +   255 +   259 +   263 +   267 +   271 +   275 +   279 +   283 +   287 +   288 +   289 + 
YnVuZGxlZC9mbGFzay9kb2NzLy5naXRpZ25vcmU=

 0 + _build
YnVuZGxlZC9mbGFzay9kb2NzL01ha2VmaWxl

 0 + # Makefile for Sphinx documentation 1 + # 2 + 3 + # You can set these variables from the command line. 4 + SPHINXOPTS = 5 + SPHINXBUILD = sphinx-build 6 + PAPER = 7 + BUILDDIR = _build 8 + 9 + # Internal variables. 10 + PAPEROPT_a4 = -D latex_paper_size=a4 11 + PAPEROPT_letter = -D latex_paper_size=letter 12 + ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees$(PAPEROPT_$(PAPER))$(SPHINXOPTS) . 13 + 14 + .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp epub latex changes linkcheck doctest 15 + 16 + help: 17 +  @echo "Please use \make ' where is one of" 18 +  @echo " html to make standalone HTML files" 19 +  @echo " dirhtml to make HTML files named index.html in directories" 20 +  @echo " singlehtml to make a single large HTML file" 21 +  @echo " pickle to make pickle files" 22 +  @echo " json to make JSON files" 23 +  @echo " htmlhelp to make HTML files and a HTML help project" 24 +  @echo " qthelp to make HTML files and a qthelp project" 25 +  @echo " devhelp to make HTML files and a Devhelp project" 26 +  @echo " epub to make an epub" 27 +  @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 28 +  @echo " latexpdf to make LaTeX files and run them through pdflatex" 29 +  @echo " changes to make an overview of all changed/added/deprecated items" 30 +  @echo " linkcheck to check all external links for integrity" 31 +  @echo " doctest to run all doctests embedded in the documentation (if enabled)" 32 + 33 + clean: 34 +  -rm -rf $(BUILDDIR)/* 35 + 36 + html: 37 + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS)$(BUILDDIR)/html 38 +  @echo 39 +  @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 40 + 41 + dirhtml: 42 + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS)$(BUILDDIR)/dirhtml 43 +  @echo 44 +  @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 45 + 46 + singlehtml: 47 + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS)$(BUILDDIR)/singlehtml 48 +  @echo 49 +  @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 50 + 51 + pickle: 52 + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS)$(BUILDDIR)/pickle 53 +  @echo 54 +  @echo "Build finished; now you can process the pickle files." 55 + 56 + json: 57 +  $(SPHINXBUILD) -b json$(ALLSPHINXOPTS) $(BUILDDIR)/json 58 +  @echo 59 +  @echo "Build finished; now you can process the JSON files." 60 + 61 + htmlhelp: 62 + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS)$(BUILDDIR)/htmlhelp 63 +  @echo 64 +  @echo "Build finished; now you can run HTML Help Workshop with the" \ 65 +  ".hhp project file in $(BUILDDIR)/htmlhelp." 66 + 67 + qthelp: 68 + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS)$(BUILDDIR)/qthelp 69 +  @echo 70 +  @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 71 +  ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 72 +  @echo "# qcollectiongenerator$(BUILDDIR)/qthelp/Flask.qhcp" 73 +  @echo "To view the help file:" 74 +  @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Flask.qhc" 75 + 76 + devhelp: 77 + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) _build/devhelp 78 +  @echo 79 +  @echo "Build finished." 80 +  @echo "To view the help file:" 81 +  @echo "# mkdir -p $$HOME/.local/share/devhelp/Flask" 82 +  @echo "# ln -s _build/devhelp$$HOME/.local/share/devhelp/Flask" 83 +  @echo "# devhelp" 84 + 85 + epub: 86 + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS)$(BUILDDIR)/epub 87 +  @echo 88 +  @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 89 + 90 + latex: 91 + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS)$(BUILDDIR)/latex 92 +  @echo 93 +  @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 94 +  @echo "Run \make all-pdf' or \make all-ps' in that directory to" \ 95 +  "run these through (pdf)latex." 96 + 97 + latexpdf: latex 98 + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex 99 +  @echo "Running LaTeX files through pdflatex..." 100 +  make -C _build/latex all-pdf 101 +  @echo "pdflatex finished; the PDF files are in _build/latex." 102 + 103 + changes: 104 + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS)$(BUILDDIR)/changes 105 +  @echo 106 +  @echo "The overview file is in $(BUILDDIR)/changes." 107 + 108 + linkcheck: 109 + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS)$(BUILDDIR)/linkcheck 110 +  @echo 111 +  @echo "Link check complete; look for any errors in the above output " \ 112 +  "or in $(BUILDDIR)/linkcheck/output.txt." 113 + 114 + doctest: 115 + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS)$(BUILDDIR)/doctest 116 +  @echo "Testing of doctests in the sources finished, look at the " \ 117 +  "results in $(BUILDDIR)/doctest/output.txt." YnVuZGxlZC9mbGFzay9kb2NzL19zdGF0aWMvZGVidWdnZXIucG5n ### bundled/flask/docs/_static/debugger.png↓  … skipped 2278 lines … YnVuZGxlZC9mbGFzay9kb2NzL19zdGF0aWMvZmxhc2sucG5n ### bundled/flask/docs/_static/flask.png↓  … skipped 192 lines … YnVuZGxlZC9mbGFzay9kb2NzL19zdGF0aWMvZmxhc2tyLnBuZw== ### bundled/flask/docs/_static/flaskr.png↓  … skipped 947 lines … YnVuZGxlZC9mbGFzay9kb2NzL19zdGF0aWMvbG9nby1mdWxsLnBuZw== ### bundled/flask/docs/_static/logo-full.png↓  … skipped 400 lines … YnVuZGxlZC9mbGFzay9kb2NzL19zdGF0aWMvbm8ucG5n ### bundled/flask/docs/_static/no.png↓  … skipped 7 lines … YnVuZGxlZC9mbGFzay9kb2NzL19zdGF0aWMvdG91Y2gtaWNvbi5wbmc= ### bundled/flask/docs/_static/touch-icon.png↓  … skipped 69 lines … YnVuZGxlZC9mbGFzay9kb2NzL19zdGF0aWMveWVzLnBuZw== ### bundled/flask/docs/_static/yes.png↓  … skipped 6 lines … YnVuZGxlZC9mbGFzay9kb2NzL190ZW1wbGF0ZXMvc2lkZWJhcmludHJvLmh0bWw= ### bundled/flask/docs/_templates/sidebarintro.html↓  0 +  About Flask  1 +   2 +  Flask is a micro webdevelopment framework for Python. You are currently 3 +  looking at the documentation of the development version. Things are 4 +  not stable yet, but if you have some feedback, 5 +  let me know. 6 +   7 +  Other Formats  8 +   9 +  You can download the documentation in other formats as well: 10 +   11 +   15 +  Useful Links  16 +   YnVuZGxlZC9mbGFzay9kb2NzL190ZW1wbGF0ZXMvc2lkZWJhcmxvZ28uaHRtbA== ### bundled/flask/docs/_templates/sidebarlogo.html↓  0 +  YnVuZGxlZC9mbGFzay9kb2NzL2FwaS5yc3Q= ### bundled/flask/docs/api.rst↓  0 + .. _api: 1 + 2 + API 3 + === 4 + 5 + .. module:: flask 6 + 7 + This part of the documentation covers all the interfaces of Flask. For 8 + parts where Flask depends on external libraries, we document the most 9 + important right here and provide links to the canonical documentation. 10 + 11 + 12 + Application Object 13 + ------------------ 14 + 15 + .. autoclass:: Flask 16 +  :members: 17 +  :inherited-members: 18 + 19 + 20 + Module Objects 21 + -------------- 22 + 23 + .. autoclass:: Module 24 +  :members: 25 +  :inherited-members: 26 + 27 + Incoming Request Data 28 + --------------------- 29 + 30 + .. autoclass:: Request 31 + 32 + .. class:: request 33 + 34 +  To access incoming request data, you can use the global request 35 +  object. Flask parses incoming request data for you and gives you 36 +  access to it through that global object. Internally Flask makes 37 +  sure that you always get the correct data for the active thread if you 38 +  are in a multithreaded environment. 39 + 40 +  This is a proxy. See :ref:notes-on-proxies for more information. 41 + 42 +  The request object is an instance of a :class:~werkzeug.Request 43 +  subclass and provides all of the attributes Werkzeug defines. This 44 +  just shows a quick overview of the most important ones. 45 + 46 +  .. attribute:: form 47 + 48 +  A :class:~werkzeug.MultiDict with the parsed form data from POST 49 +  or PUT requests. Please keep in mind that file uploads will not 50 +  end up here, but instead in the :attr:files attribute. 51 + 52 +  .. attribute:: args 53 + 54 +  A :class:~werkzeug.MultiDict with the parsed contents of the query 55 +  string. (The part in the URL after the question mark). 56 + 57 +  .. attribute:: values 58 + 59 +  A :class:~werkzeug.CombinedMultiDict with the contents of both 60 +  :attr:form and :attr:args. 61 + 62 +  .. attribute:: cookies 63 + 64 +  A :class:dict with the contents of all cookies transmitted with 65 +  the request. 66 + 67 +  .. attribute:: stream 68 + 69 +  If the incoming form data was not encoded with a known mimetype 70 +  the data is stored unmodified in this stream for consumption. Most 71 +  of the time it is a better idea to use :attr:data which will give 72 +  you that data as a string. The stream only returns the data once. 73 + 74 +  .. attribute:: data 75 + 76 +  Contains the incoming request data as string in case it came with 77 +  a mimetype Flask does not handle. 78 + 79 +  .. attribute:: files 80 + 81 +  A :class:~werkzeug.MultiDict with files uploaded as part of a 82 +  POST or PUT request. Each file is stored as 83 +  :class:~werkzeug.FileStorage object. It basically behaves like a 84 +  standard file object you know from Python, with the difference that 85 +  it also has a :meth:~werkzeug.FileStorage.save function that can 86 +  store the file on the filesystem. 87 + 88 +  .. attribute:: environ 89 + 90 +  The underlying WSGI environment. 91 + 92 +  .. attribute:: method 93 + 94 +  The current request method (POST, GET etc.) 95 + 96 +  .. attribute:: path 97 +  .. attribute:: script_root 98 +  .. attribute:: url 99 +  .. attribute:: base_url 100 +  .. attribute:: url_root 101 + 102 +  Provides different ways to look at the current URL. Imagine your 103 +  application is listening on the following URL:: 104 + 105 +  http://www.example.com/myapplication 106 + 107 +  And a user requests the following URL:: 108 + 109 +  http://www.example.com/myapplication/page.html?x=y 110 + 111 +  In this case the values of the above mentioned attributes would be 112 +  the following: 113 + 114 +  ============= ====================================================== 115 +  path /page.html 116 +  script_root /myapplication 117 +  base_url http://www.example.com/myapplication/page.html 118 +  url http://www.example.com/myapplication/page.html?x=y 119 +  url_root http://www.example.com/myapplication/ 120 +  ============= ====================================================== 121 + 122 +  .. attribute:: is_xhr 123 + 124 +  True if the request was triggered via a JavaScript 125 +  XMLHttpRequest. This only works with libraries that support the 126 +  X-Requested-With header and set it to XMLHttpRequest. 127 +  Libraries that do that are prototype, jQuery and Mochikit and 128 +  probably some more. 129 + 130 +  .. attribute:: json 131 + 132 +  Contains the parsed body of the JSON request if the mimetype of 133 +  the incoming data was application/json. This requires Python 2.6 134 +  or an installed version of simplejson. 135 + 136 + Response Objects 137 + ---------------- 138 + 139 + .. autoclass:: flask.Response 140 +  :members: set_cookie, data, mimetype 141 + 142 +  .. attribute:: headers 143 + 144 +  A :class:Headers object representing the response headers. 145 + 146 +  .. attribute:: status_code 147 + 148 +  The response status as integer. 149 + 150 + 151 + Sessions 152 + -------- 153 + 154 + If you have the :attr:Flask.secret_key set you can use sessions in Flask 155 + applications. A session basically makes it possible to remember 156 + information from one request to another. The way Flask does this is by 157 + using a signed cookie. So the user can look at the session contents, but 158 + not modify it unless he knows the secret key, so make sure to set that to 159 + something complex and unguessable. 160 + 161 + To access the current session you can use the :class:session object: 162 + 163 + .. class:: session 164 + 165 +  The session object works pretty much like an ordinary dict, with the 166 +  difference that it keeps track on modifications. 167 + 168 +  This is a proxy. See :ref:notes-on-proxies for more information. 169 + 170 +  The following attributes are interesting: 171 + 172 +  .. attribute:: new 173 + 174 +  True if the session is new, False otherwise. 175 + 176 +  .. attribute:: modified 177 + 178 +  True if the session object detected a modification. Be advised 179 +  that modifications on mutable structures are not picked up 180 +  automatically, in that situation you have to explicitly set the 181 +  attribute to True yourself. Here an example:: 182 + 183 +  # this change is not picked up because a mutable object (here 184 +  # a list) is changed. 185 +  session['objects'].append(42) 186 +  # so mark it as modified yourself 187 +  session.modified = True 188 + 189 +  .. attribute:: permanent 190 + 191 +  If set to True the session lives for 192 +  :attr:~flask.Flask.permanent_session_lifetime seconds. The 193 +  default is 31 days. If set to False (which is the default) the 194 +  session will be deleted when the user closes the browser. 195 + 196 + 197 + Application Globals 198 + ------------------- 199 + 200 + To share data that is valid for one request only from one function to 201 + another, a global variable is not good enough because it would break in 202 + threaded environments. Flask provides you with a special object that 203 + ensures it is only valid for the active request and that will return 204 + different values for each request. In a nutshell: it does the right 205 + thing, like it does for :class:request and :class:session. 206 + 207 + .. data:: g 208 + 209 +  Just store on this whatever you want. For example a database 210 +  connection or the user that is currently logged in. 211 + 212 +  This is a proxy. See :ref:notes-on-proxies for more information. 213 + 214 + 215 + Useful Functions and Classes 216 + ---------------------------- 217 + 218 + .. data:: current_app 219 + 220 +  Points to the application handling the request. This is useful for 221 +  extensions that want to support multiple applications running side 222 +  by side. 223 + 224 +  This is a proxy. See :ref:notes-on-proxies for more information. 225 + 226 + .. autofunction:: url_for 227 + 228 + .. function:: abort(code) 229 + 230 +  Raises an :exc:~werkzeug.exception.HTTPException for the given 231 +  status code. For example to abort request handling with a page not 232 +  found exception, you would call abort(404). 233 + 234 +  :param code: the HTTP error code. 235 + 236 + .. autofunction:: redirect 237 + 238 + .. autofunction:: make_response 239 + 240 + .. autofunction:: send_file 241 + 242 + .. autofunction:: send_from_directory 243 + 244 + .. autofunction:: escape 245 + 246 + .. autoclass:: Markup 247 +  :members: escape, unescape, striptags 248 + 249 + Message Flashing 250 + ---------------- 251 + 252 + .. autofunction:: flash 253 + 254 + .. autofunction:: get_flashed_messages 255 + 256 + Returning JSON 257 + -------------- 258 + 259 + .. autofunction:: jsonify 260 + 261 + .. data:: json 262 + 263 +  If JSON support is picked up, this will be the module that Flask is 264 +  using to parse and serialize JSON. So instead of doing this yourself:: 265 + 266 +  try: 267 +  import simplejson as json 268 +  except ImportError: 269 +  import json 270 + 271 +  You can instead just do this:: 272 + 273 +  from flask import json 274 + 275 +  For usage examples, read the :mod:json documentation. 276 + 277 +  The :func:~json.dumps function of this json module is also available 278 +  as filter called |tojson in Jinja2. Note that inside script 279 +  tags no escaping must take place, so make sure to disable escaping 280 +  with |safe if you intend to use it inside script tags: 281 + 282 +  .. sourcecode:: html+jinja 283 + 284 +   287 + 288 +  Note that the |tojson filter escapes forward slashes properly. 289 + 290 + Template Rendering 291 + ------------------ 292 + 293 + .. autofunction:: render_template 294 + 295 + .. autofunction:: render_template_string 296 + 297 + .. autofunction:: get_template_attribute 298 + 299 + Configuration 300 + ------------- 301 + 302 + .. autoclass:: Config 303 +  :members: 304 + 305 + Useful Internals 306 + ---------------- 307 + 308 + .. data:: _request_ctx_stack 309 + 310 +  The internal :class:~werkzeug.LocalStack that is used to implement 311 +  all the context local objects used in Flask. This is a documented 312 +  instance and can be used by extensions and application code but the 313 +  use is discouraged in general. 314 + 315 +  The following attributes are always present on each layer of the 316 +  stack: 317 + 318 +  app 319 +  the active Flask application. 320 + 321 +  url_adapter 322 +  the URL adapter that was used to match the request. 323 + 324 +  request 325 +  the current request object. 326 + 327 +  session 328 +  the active session object. 329 + 330 +  g 331 +  an object with all the attributes of the :data:flask.g object. 332 + 333 +  flashes 334 +  an internal cache for the flashed messages. 335 + 336 +  Example usage:: 337 + 338 +  from flask import _request_ctx_stack 339 + 340 +  def get_session(): 341 +  ctx = _request_ctx_stack.top 342 +  if ctx is not None: 343 +  return ctx.session 344 + 345 +  .. versionchanged:: 0.4 346 + 347 +  The request context is automatically popped at the end of the request 348 +  for you. In debug mode the request context is kept around if 349 +  exceptions happen so that interactive debuggers have a chance to 350 +  introspect the data. With 0.4 this can also be forced for requests 351 +  that did not fail and outside of DEBUG mode. By setting 352 +  'flask._preserve_context' to True on the WSGI environment the 353 +  context will not pop itself at the end of the request. This is used by 354 +  the :meth:~flask.Flask.test_client for example to implement the 355 +  deferred cleanup functionality. 356 + 357 +  You might find this helpful for unittests where you need the 358 +  information from the context local around for a little longer. Make 359 +  sure to properly :meth:~werkzeug.LocalStack.pop the stack yourself in 360 +  that situation, otherwise your unittests will leak memory. 361 + 362 + Signals 363 + ------- 364 + 365 + .. when modifying this list, also update the one in signals.rst 366 + 367 + .. versionadded:: 0.6 368 + 369 + .. data:: signals_available 370 + 371 +  True if the signalling system is available. This is the case 372 +  when blinker_ is installed. 373 + 374 + .. data:: template_rendered 375 + 376 +  This signal is sent when a template was successfully rendered. The 377 +  signal is invoked with the instance of the template as template 378 +  and the context as dictionary (named context). 379 + 380 + .. data:: request_started 381 + 382 +  This signal is sent before any request processing started but when the 383 +  request context was set up. Because the request context is already 384 +  bound, the subscriber can access the request with the standard global 385 +  proxies such as :class:~flask.request. 386 + 387 + .. data:: request_finished 388 + 389 +  This signal is sent right before the response is sent to the client. 390 +  It is passed the response to be sent named response. 391 + 392 + .. data:: got_request_exception 393 + 394 +  This signal is sent when an exception happens during request processing. 395 +  It is sent *before* the standard exception handling kicks in and even 396 +  in debug mode, where no exception handling happens. The exception 397 +  itself is passed to the subscriber as exception. 398 + 399 + .. currentmodule:: None 400 + 401 + .. class:: flask.signals.Namespace 402 + 403 +  An alias for :class:blinker.base.Namespace if blinker is available, 404 +  otherwise a dummy class that creates fake signals. This class is 405 +  available for Flask extensions that want to provide the same fallback 406 +  system as Flask itself. 407 + 408 +  .. method:: signal(name, doc=None) 409 + 410 +  Creates a new signal for this namespace if blinker is available, 411 +  otherwise returns a fake signal that has a send method that will 412 +  do nothing but will fail with a :exc:RuntimeError for all other 413 +  operations, including connecting. 414 + 415 + .. _blinker: http://pypi.python.org/pypi/blinker 416 + 417 + .. _notes-on-proxies: 418 + 419 + Notes On Proxies 420 + ---------------- 421 + 422 + Some of the objects provided by Flask are proxies to other objects. The 423 + reason behind this is that these proxies are shared between threads and 424 + they have to dispatch to the actual object bound to a thread behind the 425 + scenes as necessary. 426 + 427 + Most of the time you don't have to care about that, but there are some 428 + exceptions where it is good to know that this object is an actual proxy: 429 + 430 + - The proxy objects do not fake their inherited types, so if you want to 431 +  perform actual instance checks, you have to do that on the instance 432 +  that is being proxied (see _get_current_object below). 433 + - if the object reference is important (so for example for sending 434 +  :ref:signals) 435 + 436 + If you need to get access to the underlying object that is proxied, you 437 + can use the :meth:~werkzeug.LocalProxy._get_current_object method:: 438 + 439 +  app = current_app._get_current_object() 440 +  my_signal.send(app) YnVuZGxlZC9mbGFzay9kb2NzL2JlY29taW5nYmlnLnJzdA== ### bundled/flask/docs/becomingbig.rst↓  0 + .. _becomingbig: 1 + 2 + Becoming Big 3 + ============ 4 + 5 + Your application is becoming more and more complex? If you suddenly 6 + realize that Flask does things in a way that does not work out for your 7 + application there are ways to deal with that. 8 + 9 + Flask is powered by Werkzeug and Jinja2, two libraries that are in use at 10 + a number of large websites out there and all Flask does is bring those 11 + two together. Being a microframework Flask does not do much more than 12 + combining existing libraries - there is not a lot of code involved. 13 + What that means for large applications is that it's very easy to take the 14 + code from Flask and put it into a new module within the applications and 15 + expand on that. 16 + 17 + Flask is designed to be extended and modified in a couple of different 18 + ways: 19 + 20 + - Flask extensions. For a lot of reusable functionality you can create 21 +  extensions. For extensions a number of hooks exist throughout Flask 22 +  with signals and callback functions. 23 + 24 + - Subclassing. The majority of functionality can be changed by creating 25 +  a new subclass of the :class:~flask.Flask class and overriding 26 +  methods provided for this exact purpose. 27 + 28 + - Forking. If nothing else works out you can just take the Flask 29 +  codebase at a given point and copy/paste it into your application 30 +  and change it. Flask is designed with that in mind and makes this 31 +  incredible easy. You just have to take the package and copy it 32 +  into your application's code and rename it (for example to 33 +  framework). Then you can start modifying the code in there. 34 + 35 + Why consider Forking? 36 + --------------------- 37 + 38 + The majority of code of Flask is within Werkzeug and Jinja2. These 39 + libraries do the majority of the work. Flask is just the paste that glues 40 + those together. For every project there is the point where the underlying 41 + framework gets in the way (due to assumptions the original developers 42 + had). This is natural because if this would not be the case, the 43 + framework would be a very complex system to begin with which causes a 44 + steep learning curve and a lot of user frustration. 45 + 46 + This is not unique to Flask. Many people use patched and modified 47 + versions of their framework to counter shortcomings. This idea is also 48 + reflected in the license of Flask. You don't have to contribute any 49 + changes back if you decide to modify the framework. 50 + 51 + The downside of forking is of course that Flask extensions will most 52 + likely break because the new framework has a different import name. 53 + Furthermore integrating upstream changes can be a complex process, 54 + depending on the number of changes. Because of that, forking should be 55 + the very last resort. 56 + 57 + Scaling like a Pro 58 + ------------------ 59 + 60 + For many web applications the complexity of the code is less an issue than 61 + the scaling for the number of users or data entries expected. Flask by 62 + itself is only limited in terms of scaling by your application code, the 63 + data store you want to use and the Python implementation and webserver you 64 + are running on. 65 + 66 + Scaling well means for example that if you double the amount of servers 67 + you get about twice the performance. Scaling bad means that if you add a 68 + new server the application won't perform any better or would not even 69 + support a second server. 70 + 71 + There is only one limiting factor regarding scaling in Flask which are 72 + the context local proxies. They depend on context which in Flask is 73 + defined as being either a thread, process or greenlet. If your server 74 + uses some kind of concurrency that is not based on threads or greenlets, 75 + Flask will no longer be able to support these global proxies. However the 76 + majority of servers are using either threads, greenlets or separate 77 + processes to achieve concurrency which are all methods well supported by 78 + the underlying Werkzeug library. 79 + 80 + Dialogue with the Community 81 + --------------------------- 82 + 83 + The Flask developers are very interested to keep everybody happy, so as 84 + soon as you find an obstacle in your way, caused by Flask, don't hesitate 85 + to contact the developers on the mailinglist or IRC channel. The best way 86 + for the Flask and Flask-extension developers to improve it for larger 87 + applications is getting feedback from users. YnVuZGxlZC9mbGFzay9kb2NzL2NoYW5nZWxvZy5yc3Q= ### bundled/flask/docs/changelog.rst↓  0 + .. include:: ../CHANGES YnVuZGxlZC9mbGFzay9kb2NzL2NvbmYucHk= ### bundled/flask/docs/conf.py↓  0 + # -*- coding: utf-8 -*- 1 + # 2 + # Flask documentation build configuration file, created by 3 + # sphinx-quickstart on Tue Apr 6 15:24:58 2010. 4 + # 5 + # This file is execfile()d with the current directory set to its containing dir. 6 + # 7 + # Note that not all possible configuration values are present in this 8 + # autogenerated file. 9 + # 10 + # All configuration values have a default; values that are commented out 11 + # serve to show the default. 12 + 13 + import sys, os 14 + 15 + # If extensions (or modules to document with autodoc) are in another directory, 16 + # add these directories to sys.path here. If the directory is relative to the 17 + # documentation root, use os.path.abspath to make it absolute, like shown here. 18 + sys.path.append(os.path.abspath('_themes')) 19 + 20 + # -- General configuration ----------------------------------------------------- 21 + 22 + # If your documentation needs a minimal Sphinx version, state it here. 23 + #needs_sphinx = '1.0' 24 + 25 + # Add any Sphinx extension module names here, as strings. They can be extensions 26 + # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 27 + extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx'] 28 + 29 + # Add any paths that contain templates here, relative to this directory. 30 + templates_path = ['_templates'] 31 + 32 + # The suffix of source filenames. 33 + source_suffix = '.rst' 34 + 35 + # The encoding of source files. 36 + #source_encoding = 'utf-8-sig' 37 + 38 + # The master toctree document. 39 + master_doc = 'index' 40 + 41 + # General information about the project. 42 + project = u'Flask' 43 + copyright = u'2010, Armin Ronacher' 44 + 45 + # The version info for the project you're documenting, acts as replacement for 46 + # |version| and |release|, also used in various other places throughout the 47 + # built documents. 48 + import pkg_resources 49 + try: 50 +  release = pkg_resources.get_distribution('Flask').version 51 + except pkg_resources.DistributionNotFound: 52 +  print 'To build the documentation, The distribution information of Flask' 53 +  print 'Has to be available. Either install the package into your' 54 +  print 'development environment or run "setup.py develop" to setup the' 55 +  print 'metadata. A virtualenv is recommended!' 56 +  sys.exit(1) 57 + del pkg_resources 58 + 59 + if 'dev' in release: 60 +  release = release.split('dev')[0] + 'dev' 61 + version = '.'.join(release.split('.')[:2]) 62 + 63 + # The language for content autogenerated by Sphinx. Refer to documentation 64 + # for a list of supported languages. 65 + #language = None 66 + 67 + # There are two options for replacing |today|: either, you set today to some 68 + # non-false value, then it is used: 69 + #today = '' 70 + # Else, today_fmt is used as the format for a strftime call. 71 + #today_fmt = '%B %d, %Y' 72 + 73 + # List of patterns, relative to source directory, that match files and 74 + # directories to ignore when looking for source files. 75 + exclude_patterns = ['_build'] 76 + 77 + # The reST default role (used for this markup: text) to use for all documents. 78 + #default_role = None 79 + 80 + # If true, '()' will be appended to :func: etc. cross-reference text. 81 + #add_function_parentheses = True 82 + 83 + # If true, the current module name will be prepended to all description 84 + # unit titles (such as .. function::). 85 + #add_module_names = True 86 + 87 + # If true, sectionauthor and moduleauthor directives will be shown in the 88 + # output. They are ignored by default. 89 + #show_authors = False 90 + 91 + # A list of ignored prefixes for module index sorting. 92 + #modindex_common_prefix = [] 93 + 94 + 95 + # -- Options for HTML output --------------------------------------------------- 96 + 97 + # The theme to use for HTML and HTML Help pages. Major themes that come with 98 + # Sphinx are currently 'default' and 'sphinxdoc'. 99 + html_theme = 'flask' 100 + 101 + # Theme options are theme-specific and customize the look and feel of a theme 102 + # further. For a list of options available for each theme, see the 103 + # documentation. 104 + html_theme_options = { 105 +  'touch_icon': 'touch-icon.png' 106 + } 107 + 108 + # Add any paths that contain custom themes here, relative to this directory. 109 + html_theme_path = ['_themes'] 110 + 111 + # The name for this set of Sphinx documents. If None, it defaults to 112 + # " v documentation". 113 + #html_title = None 114 + 115 + # A shorter title for the navigation bar. Default is the same as html_title. 116 + #html_short_title = None 117 + 118 + # The name of an image file (relative to this directory) to place at the top 119 + # of the sidebar. Do not set, template magic! 120 + #html_logo = None 121 + 122 + # The name of an image file (within the static path) to use as favicon of the 123 + # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 124 + # pixels large. 125 + #html_favicon = None 126 + 127 + # Add any paths that contain custom static files (such as style sheets) here, 128 + # relative to this directory. They are copied after the builtin static files, 129 + # so a file named "default.css" will overwrite the builtin "default.css". 130 + html_static_path = ['_static'] 131 + 132 + # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 133 + # using the given strftime format. 134 + #html_last_updated_fmt = '%b %d, %Y' 135 + 136 + # If true, SmartyPants will be used to convert quotes and dashes to 137 + # typographically correct entities. 138 + #html_use_smartypants = True 139 + 140 + # Custom sidebar templates, maps document names to template names. 141 + html_sidebars = { 142 +  'index': ['sidebarintro.html', 'sourcelink.html', 'searchbox.html'], 143 +  '**': ['sidebarlogo.html', 'localtoc.html', 'relations.html', 144 +  'sourcelink.html', 'searchbox.html'] 145 + } 146 + 147 + # Additional templates that should be rendered to pages, maps page names to 148 + # template names. 149 + #html_additional_pages = {} 150 + 151 + # If false, no module index is generated. 152 + html_use_modindex = False 153 + 154 + # If false, no index is generated. 155 + #html_use_index = True 156 + 157 + # If true, the index is split into individual pages for each letter. 158 + #html_split_index = False 159 + 160 + # If true, links to the reST sources are added to the pages. 161 + #html_show_sourcelink = True 162 + 163 + # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 164 + html_show_sphinx = False 165 + 166 + # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 167 + #html_show_copyright = True 168 + 169 + # If true, an OpenSearch description file will be output, and all pages will 170 + # contain a tag referring to it. The value of this option must be the 171 + # base URL from which the finished HTML is served. 172 + #html_use_opensearch = '' 173 + 174 + # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). 175 + #html_file_suffix = '' 176 + 177 + # Output file base name for HTML help builder. 178 + htmlhelp_basename = 'Flaskdoc' 179 + 180 + 181 + # -- Options for LaTeX output -------------------------------------------------- 182 + 183 + # Grouping the document tree into LaTeX files. List of tuples 184 + # (source start file, target name, title, author, documentclass [howto/manual]). 185 + latex_documents = [ 186 +  ('latexindex', 'Flask.tex', u'Flask Documentation', 187 +  u'Armin Ronacher', 'manual'), 188 + ] 189 + 190 + # Documents to append as an appendix to all manuals. 191 + #latex_appendices = [] 192 + 193 + # If false, no module index is generated. 194 + latex_use_modindex = False 195 + 196 + latex_elements = { 197 +  'fontpkg': r'\usepackage{mathpazo}', 198 +  'papersize': 'a4paper', 199 +  'pointsize': '12pt', 200 +  'preamble': r'\usepackage{flaskstyle}' 201 + } 202 + latex_use_parts = True 203 + 204 + latex_additional_files = ['flaskstyle.sty', 'logo.pdf'] 205 + 206 + 207 + # -- Options for Epub output --------------------------------------------------- 208 + 209 + # Bibliographic Dublin Core info. 210 + #epub_title = '' 211 + #epub_author = '' 212 + #epub_publisher = '' 213 + #epub_copyright = '' 214 + 215 + # The language of the text. It defaults to the language option 216 + # or en if the language is not set. 217 + #epub_language = '' 218 + 219 + # The scheme of the identifier. Typical schemes are ISBN or URL. 220 + #epub_scheme = '' 221 + 222 + # The unique identifier of the text. This can be a ISBN number 223 + # or the project homepage. 224 + #epub_identifier = '' 225 + 226 + # A unique identification for the text. 227 + #epub_uid = '' 228 + 229 + # HTML files that should be inserted before the pages created by sphinx. 230 + # The format is a list of tuples containing the path and title. 231 + #epub_pre_files = [] 232 + 233 + # HTML files shat should be inserted after the pages created by sphinx. 234 + # The format is a list of tuples containing the path and title. 235 + #epub_post_files = [] 236 + 237 + # A list of files that should not be packed into the epub file. 238 + #epub_exclude_files = [] 239 + 240 + # The depth of the table of contents in toc.ncx. 241 + #epub_tocdepth = 3 242 + 243 + intersphinx_mapping = { 244 +  'http://docs.python.org/dev': None, 245 +  'http://werkzeug.pocoo.org/docs/': None, 246 +  'http://www.sqlalchemy.org/docs/': None, 247 +  'http://wtforms.simplecodes.com/docs/0.5/': None, 248 +  'http://discorporate.us/projects/Blinker/docs/1.1/': None 249 + } 250 + 251 + pygments_style = 'flask_theme_support.FlaskyStyle' 252 + 253 + # fall back if theme is not there 254 + try: 255 +  __import__('flask_theme_support') 256 + except ImportError, e: 257 +  print '-' * 74 258 +  print 'Warning: Flask themes unavailable. Building with default theme' 259 +  print 'If you want the Flask themes, run this command and build again:' 260 +  print 261 +  print ' git submodule update --init' 262 +  print '-' * 74 263 + 264 +  pygments_style = 'tango' 265 +  html_theme = 'default' 266 +  html_theme_options = {} YnVuZGxlZC9mbGFzay9kb2NzL2NvbmZpZy5yc3Q= ### bundled/flask/docs/config.rst↓  0 + .. _config: 1 + 2 + Configuration Handling 3 + ====================== 4 + 5 + .. versionadded:: 0.3 6 + 7 + Applications need some kind of configuration. There are different things 8 + you might want to change like toggling debug mode, the secret key, and a 9 + lot of very similar things. 10 + 11 + The way Flask is designed usually requires the configuration to be 12 + available when the application starts up. You can hardcode the 13 + configuration in the code, which for many small applications is not 14 + actually that bad, but there are better ways. 15 + 16 + Independent of how you load your config, there is a config object 17 + available which holds the loaded configuration values: 18 + The :attr:~flask.Flask.config attribute of the :class:~flask.Flask 19 + object. This is the place where Flask itself puts certain configuration 20 + values and also where extensions can put their configuration values. But 21 + this is also where you can have your own configuration. 22 + 23 + Configuration Basics 24 + -------------------- 25 + 26 + The :attr:~flask.Flask.config is actually a subclass of a dictionary and 27 + can be modified just like any dictionary:: 28 + 29 +  app = Flask(__name__) 30 +  app.config['DEBUG'] = True 31 + 32 + Certain configuration values are also forwarded to the 33 + :attr:~flask.Flask object so that you can read and write them from 34 + there:: 35 + 36 +  app.debug = True 37 + 38 + To update multiple keys at once you can use the :meth:dict.update 39 + method:: 40 + 41 +  app.config.update( 42 +  DEBUG=True, 43 +  SECRET_KEY='...' 44 +  ) 45 + 46 + Builtin Configuration Values 47 + ---------------------------- 48 + 49 + The following configuration values are used internally by Flask: 50 + 51 + .. tabularcolumns:: |p{6.5cm}|p{8.5cm}| 52 + 53 + =============================== ========================================= 54 + DEBUG enable/disable debug mode 55 + TESTING enable/disable testing mode 56 + PROPAGATE_EXCEPTIONS explicitly enable or disable the 57 +  propagation of exceptions. If not set or 58 +  explicitly set to None this is 59 +  implicitly true if either TESTING or 60 +  DEBUG is true. 61 + SECRET_KEY the secret key 62 + SESSION_COOKIE_NAME the name of the session cookie 63 + PERMANENT_SESSION_LIFETIME the lifetime of a permanent session as 64 +  :class:datetime.timedelta object. 65 + USE_X_SENDFILE enable/disable x-sendfile 66 + LOGGER_NAME the name of the logger 67 + SERVER_NAME the name of the server. Required for 68 +  subdomain support (e.g.: 'localhost') 69 + MAX_CONTENT_LENGTH If set to a value in bytes, Flask will 70 +  reject incoming requests with a 71 +  content length greater than this by 72 +  returning a 413 status code. 73 + =============================== ========================================= 74 + 75 + .. admonition:: More on SERVER_NAME 76 + 77 +  The SERVER_NAME key is used for the subdomain support. Because 78 +  Flask cannot guess the subdomain part without the knowledge of the 79 +  actual server name, this is required if you want to work with 80 +  subdomains. This is also used for the session cookie. 81 + 82 +  Please keep in mind that not only Flask has the problem of not knowing 83 +  what subdomains are, your web browser does as well. Most modern web 84 +  browsers will not allow cross-subdomain cookies to be set on a 85 +  server name without dots in it. So if your server name is 86 +  'localhost' you will not be able to set a cookie for 87 +  'localhost' and every subdomain of it. Please chose a different 88 +  server name in that case, like 'myapplication.local' and add 89 +  this name + the subdomains you want to use into your host config 90 +  or setup a local bind_. 91 + 92 + .. _bind: https://www.isc.org/software/bind 93 + 94 + .. versionadded:: 0.4 95 +  LOGGER_NAME 96 + 97 + .. versionadded:: 0.5 98 +  SERVER_NAME 99 + 100 + .. versionadded:: 0.6 101 +  MAX_CONTENT_LENGTH 102 + 103 + .. versionadded:: 0.7 104 +  PROPAGATE_EXCEPTIONS 105 + 106 + Configuring from Files 107 + ---------------------- 108 + 109 + Configuration becomes more useful if you can configure from a file, and 110 + ideally that file would be outside of the actual application package so that 111 + you can install the package with distribute (:ref:distribute-deployment) 112 + and still modify that file afterwards. 113 + 114 + So a common pattern is this:: 115 + 116 +  app = Flask(__name__) 117 +  app.config.from_object('yourapplication.default_settings') 118 +  app.config.from_envvar('YOURAPPLICATION_SETTINGS') 119 + 120 + This first loads the configuration from the 121 + yourapplication.default_settings module and then overrides the values 122 + with the contents of the file the :envvar:YOURAPPLICATION_SETTINGS 123 + environment variable points to. This environment variable can be set on 124 + Linux or OS X with the export command in the shell before starting the 125 + server:: 126 + 127 + $ export YOURAPPLICATION_SETTINGS=/path/to/settings.cfg 128 +  $python run-app.py 129 +  * Running on http://127.0.0.1:5000/ 130 +  * Restarting with reloader... 131 + 132 + On Windows systems use the set builtin instead:: 133 + 134 +  >set YOURAPPLICATION_SETTINGS=\path\to\settings.cfg 135 + 136 + The configuration files themselves are actual Python files. Only values 137 + in uppercase are actually stored in the config object later on. So make 138 + sure to use uppercase letters for your config keys. 139 + 140 + Here is an example configuration file:: 141 + 142 +  DEBUG = False 143 +  SECRET_KEY = '?\xbf,\xb4\x8d\xa3"<\x9c\xb0@\x0f5\xab,w\xee\x8d$0\x13\x8b83' 144 + 145 + Make sure to load the configuration very early on so that extensions have 146 + the ability to access the configuration when starting up. There are other 147 + methods on the config object as well to load from individual files. For a 148 + complete reference, read the :class:~flask.Config object's 149 + documentation. 150 + 151 + 152 + Configuration Best Practices 153 + ---------------------------- 154 + 155 + The downside with the approach mentioned earlier is that it makes testing 156 + a little harder. There is no one 100% solution for this problem in 157 + general, but there are a couple of things you can do to improve that 158 + experience: 159 + 160 + 1. create your application in a function and register modules on it. 161 +  That way you can create multiple instances of your application with 162 +  different configurations attached which makes unittesting a lot 163 +  easier. You can use this to pass in configuration as needed. 164 + 165 + 2. Do not write code that needs the configuration at import time. If you 166 +  limit yourself to request-only accesses to the configuration you can 167 +  reconfigure the object later on as needed. 168 + 169 + 170 + Development / Production 171 + ------------------------ 172 + 173 + Most applications need more than one configuration. There will at least 174 + be a separate configuration for a production server and one used during 175 + development. The easiest way to handle this is to use a default 176 + configuration that is always loaded and part of version control, and a 177 + separate configuration that overrides the values as necessary as mentioned 178 + in the example above:: 179 + 180 +  app = Flask(__name__) 181 +  app.config.from_object('yourapplication.default_settings') 182 +  app.config.from_envvar('YOURAPPLICATION_SETTINGS') 183 + 184 + Then you just have to add a separate config.py file and export 185 + YOURAPPLICATION_SETTINGS=/path/to/config.py and you are done. However 186 + there are alternative ways as well. For example you could use imports or 187 + subclassing. 188 + 189 + What is very popular in the Django world is to make the import explicit in 190 + the config file by adding an from yourapplication.default_settings 191 + import * to the top of the file and then overriding the changes by hand. 192 + You could also inspect an environment variable like 193 + YOURAPPLICATION_MODE and set that to production, development etc 194 + and import different hardcoded files based on that. 195 + 196 + An interesting pattern is also to use classes and inheritance for 197 + configuration:: 198 + 199 +  class Config(object): 200 +  DEBUG = False 201 +  TESTING = False 202 +  DATABASE_URI = 'sqlite://:memory:' 203 + 204 +  class ProductionConfig(Config): 205 +  DATABASE_URI = 'mysql://user@localhost/foo' 206 +   207 +  class DevelopmentConfig(Config): 208 +  DEBUG = True 209 + 210 +  class TestinConfig(Config): 211 +  TESTING = True 212 + 213 + To enable such a config you just have to call into 214 + :meth:~flask.Config.from_object:: 215 + 216 +  app.config.from_object('configmodule.ProductionConfig') 217 + 218 + There are many different ways and it's up to you how you want to manage 219 + your configuration files. However here a list of good recommendations: 220 + 221 + - keep a default configuration in version control. Either populate the 222 +  config with this default configuration or import it in your own 223 +  configuration files before overriding values. 224 + - use an environment variable to switch between the configurations. 225 +  This can be done from outside the Python interpreter and makes 226 +  development and deployment much easier because you can quickly and 227 +  easily switch between different configs without having to touch the 228 +  code at all. If you are working often on different projects you can 229 +  even create your own script for sourcing that activates a virtualenv 230 +  and exports the development configuration for you. 231 + - Use a tool like fabric_ in production to push code and 232 +  configurations separately to the production server(s). For some 233 +  details about how to do that, head over to the :ref:deploy pattern. 234 + 235 + .. _fabric: http://fabfile.org/
YnVuZGxlZC9mbGFzay9kb2NzL2NvbnRlbnRzLnJzdC5pbmM=

 0 + User's Guide 1 + ------------ 2 + 3 + This part of the documentation, which is mostly prose, begins with some 4 + background information about Flask, then focuses on step-by-step 5 + instructions for web development with Flask. 6 + 7 + .. toctree:: 8 +  :maxdepth: 2 9 + 10 +  foreword 11 +  installation 12 +  quickstart 13 +  tutorial/index 14 +  templating 15 +  testing 16 +  errorhandling 17 +  config 18 +  signals 19 +  shell 20 +  patterns/index 21 +  deploying/index 22 +  becomingbig 23 + 24 + API Reference 25 + ------------- 26 + 27 + If you are looking for information on a specific function, class or 28 + method, this part of the documentation is for you. 29 + 30 + .. toctree:: 31 +  :maxdepth: 2 32 + 33 +  api 34 + 35 + Additional Notes 36 + ---------------- 37 + 38 + Design notes, legal information and changelog are here for the interested. 39 + 40 + .. toctree:: 41 +  :maxdepth: 2 42 + 43 +  design 44 +  htmlfaq 45 +  security 46 +  unicode 47 +  extensiondev 48 +  styleguide 49 +  upgrading 50 +  changelog 51 +  license
 0 + CGI 1 + === 2 + 3 + If all other deployment methods do not work, CGI will work for sure. CGI 4 + is supported by all major servers but usually has a less-than-optimal 5 + performance. 6 + 7 + This is also the way you can use a Flask application on Google's 8 + App Engine_, there however the execution does happen in a CGI-like 9 + environment. The application's performance is unaffected because of that. 10 + 11 + .. admonition:: Watch Out 12 + 13 +  Please make sure in advance that your app.run() call you might 14 +  have in your application file, is inside an if __name__ == 15 +  '__main__': or moved to a separate file. Just make sure it's not 16 +  called because this will always start a local WSGI server which we do 17 +  not want if we deploy that application to CGI / app engine. 18 + 19 + .. _App Engine: http://code.google.com/appengine/ 20 + 21 + Creating a .cgi file 22 + ---------------------- 23 + 24 + First you need to create the CGI application file. Let's call it 25 + yourapplication.cgi:: 26 + 27 +  #!/usr/bin/python 28 +  from wsgiref.handlers import CGIHandler 29 +  from yourapplication import app 30 + 31 +  CGIHandler().run(app) 32 + 33 + Server Setup 34 + ------------ 35 + 36 + Usually there are two ways to configure the server. Either just copy the 37 + .cgi into a cgi-bin (and use mod_rewrite or something similar to 38 + rewrite the URL) or let the server point to the file directly. 39 + 40 + In Apache for example you can put a like like this into the config: 41 + 42 + .. sourcecode:: apache 43 + 44 +  ScriptAlias /app /path/to/the/application.cgi 45 + 46 + For more information consult the documentation of your webserver.
 0 + FastCGI 1 + ======= 2 + 3 + A very popular deployment setup on servers like lighttpd_ and nginx_ 4 + is FastCGI. To use your WSGI application with any of them you will need 5 + a FastCGI server first. 6 + 7 + The most popular one is flup_ which we will use for this guide. Make 8 + sure to have it installed. 9 + 10 + .. admonition:: Watch Out 11 + 12 +  Please make sure in advance that your app.run() call you might 13 +  have in your application file, is inside an if __name__ == 14 +  '__main__': or moved to a separate file. Just make sure it's not 15 +  called because this will always start a local WSGI server which we do 16 +  not want if we deploy that application to FastCGI. 17 + 18 + Creating a .fcgi file 19 + ----------------------- 20 + 21 + First you need to create the FastCGI server file. Let's call it 22 + yourapplication.fcgi:: 23 + 24 +  #!/usr/bin/python 25 +  from flup.server.fcgi import WSGIServer 26 +  from yourapplication import app 27 + 28 +  WSGIServer(app).run() 29 + 30 + This is enough for Apache to work, however lighttpd and nginx need a 31 + socket to communicate with the FastCGI server. For that to work you 32 + need to pass the path to the socket to the 33 + :class:~flup.server.fcgi.WSGIServer:: 34 + 35 +  WSGIServer(application, bindAddress='/path/to/fcgi.sock').run() 36 + 37 + The path has to be the exact same path you define in the server 38 + config. 39 + 40 + Save the yourapplication.fcgi file somewhere you will find it again. 41 + It makes sense to have that in /var/www/yourapplication or something 42 + similar. 43 + 44 + Make sure to set the executable bit on that file so that the servers 45 + can execute it: 46 + 47 + .. sourcecode:: text 48 + 49 +  # chmod +x /var/www/yourapplication/yourapplication.fcgi 50 + 51 + Configuring lighttpd 52 + -------------------- 53 + 54 + A basic FastCGI configuration for lighttpd looks like that:: 55 + 56 +  fastcgi.server = ("/yourapplication" => 57 +  "yourapplication" => ( 58 +  "socket" => "/tmp/yourapplication-fcgi.sock", 59 +  "bin-path" => "/var/www/yourapplication/yourapplication.fcgi", 60 +  "check-local" => "disable" 61 +  ) 62 +  ) 63 + 64 + This configuration binds the application to /yourapplication. If you 65 + want the application to work in the URL root you have to work around a 66 + lighttpd bug with the :class:~werkzeug.contrib.fixers.LighttpdCGIRootFix 67 + middleware. 68 + 69 + Make sure to apply it only if you are mounting the application the URL 70 + root. 71 + 72 + Configuring nginx 73 + ----------------- 74 + 75 + Installing FastCGI applications on nginx is a bit different because by default 76 + no FastCGI parameters are forwarded. 77 + 78 + A basic flask FastCGI configuration for nginx looks like this:: 79 + 80 +  location = /yourapplication { rewrite ^ /yourapplication/ last; } 81 +  location /yourapplication { try_files $uri @yourapplication; } 82 +  location @yourapplication { 83 +  include fastcgi_params; 84 +  fastcgi_split_path_info ^(/yourapplication)(.*)$; 85 +  fastcgi_param PATH_INFO $fastcgi_path_info; 86 +  fastcgi_param SCRIPT_NAME$fastcgi_script_name; 87 +  fastcgi_pass unix:/tmp/yourapplication-fcgi.sock; 88 +  } 89 + 90 + This configuration binds the application to /yourapplication. If you want 91 + to have it in the URL root it's a bit simpler because you don't have to figure 92 + out how to calculate PATH_INFO and SCRIPT_NAME:: 93 + 94 +  location / { try_files $uri @yourapplication; } 95 +  location @yourapplication { 96 +  include fastcgi_params; 97 +  fastcgi_param PATH_INFO$fastcgi_script_name; 98 +  fastcgi_param SCRIPT_NAME ""; 99 +  fastcgi_pass unix:/tmp/yourapplication-fcgi.sock; 100 +  } 101 + 102 + Since Nginx doesn't load FastCGI apps, you have to do it by yourself. You 103 + can either write an init.d script for that or execute it inside a screen 104 + session:: 105 + 106 +  $screen 107 + $ /var/www/yourapplication/yourapplication.fcgi 108 + 109 + Debugging 110 + --------- 111 + 112 + FastCGI deployments tend to be hard to debug on most webservers. Very often the 113 + only thing the server log tells you is something along the lines of "premature 114 + end of headers". In order to debug the application the only thing that can 115 + really give you ideas why it breaks is switching to the correct user and