Skip to content
Myr

Merge branch '1.0-maintenance'

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parents b78ebac, a656025 · Browse files · 13 files+68 added−57 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

13 files+68 added−57 removed

  • other:+68 added−57 removed

13 files+68 added−57 removed

modified:docs/tutorial/blog.rst+1 added-1 removed
312 unmodified lines
313------314315The delete view doesn't have its own template, the delete button is part316of ``update.html`` and posts to the ``/<id>/delete`` URL. Since there317is no template, it will only handle the ``POST`` method then redirect317is no template, it will only handle the ``POST`` method and then redirect318to the ``index`` view.319320.. code-block:: python321 :caption: ``flaskr/blog.py``
15 unmodified lines
modified:docs/tutorial/database.rst+1 added-1 removed
147 unmodified lines
148Register with the Application149-----------------------------150151The ``close_db`` and ``init_db_command`` functions need to be registered152with the application instance, otherwise they won't be used by the152with the application instance; otherwise, they won't be used by the153application. However, since you're using a factory function, that154instance isn't available when writing the functions. Instead, write a155function that takes an application and does the registration.156
57 unmodified lines
modified:docs/api.rst+4 added-4 removed
310 unmodified lines
311 will have that method called and then the return value is serialized312 as string.313314The :func:`~htmlsafe_dumps` function of this json module is also available315as filter called ``|tojson`` in Jinja2. Note that inside ``script``316tags no escaping must take place, so make sure to disable escaping317with ``|safe`` if you intend to use it inside ``script`` tags unless318you are using Flask 0.10 which implies that:315as a filter called ``|tojson`` in Jinja2. Note that in versions of Flask prior316to Flask 0.10, you must disable escaping with ``|safe`` if you intend to use317``|tojson`` output inside ``script`` tags. In Flask 0.10 and above, this318happens automatically (but it's harmless to include ``|safe`` anyway).319320.. sourcecode:: html+jinja321322 <script type=text/javascript>
511 unmodified lines
modified:docs/blueprints.rst+4 added-3 removed
73 unmodified lines
74 except TemplateNotFound:75 abort(404)7677When you bind a function with the help of the ``@simple_page.route``78decorator the blueprint will record the intention of registering the79function `show` on the application when it's later registered.78decorator, the blueprint will record the intention of registering the79function ``show`` on the application when it's later registered.80Additionally it will prefix the endpoint of the function with the81name of the blueprint which was given to the :class:`Blueprint`82constructor (in this case also ``simple_page``).82constructor (in this case also ``simple_page``). The blueprint's name83does not modify the URL, only the endpoint.8485Registering Blueprints86----------------------87
190 unmodified lines
modified:docs/installation.rst+3 added-3 removed
89 unmodified lines
90.. code-block:: bat9192 $ py -3 -m venv venv9394If you needed to install virtualenv because you are on an older version of95Python, use the following command instead:94If you needed to install virtualenv because you are using Python 2, use95the following command instead:9697.. code-block:: sh9899 $ virtualenv venv99 $ python2 -m virtualenv venv100101On Windows:102103.. code-block:: bat
83 unmodified lines
modified:docs/templating.rst+14 added-5 removed
108 unmodified lines
109 This function converts the given object into JSON representation. This110 is for example very helpful if you try to generate JavaScript on the111 fly.112113 Note that inside ``script`` tags no escaping must take place, so make114 sure to disable escaping with ``|safe`` before Flask 0.10 if you intend115 to use it inside ``script`` tags:116113 .. sourcecode:: html+jinja114115 <script type=text/javascript>120 doSomethingWith({{ user.username|tojson|safe }});116 doSomethingWith({{ user.username|tojson }});117 </script>118119 It is also safe to use the output of `|tojson` in a *single-quoted* HTML120 attribute:121122 .. sourcecode:: html+jinja123124 <button onclick='doSomethingWith({{ user.username|tojson }})'>125 Click me126 </button>127128 Note that in versions of Flask prior to 0.10, if using the output of129 ``|tojson`` inside ``script``, make sure to disable escaping with ``|safe``.130 In Flask 0.10 and above, this happens automatically.131132Controlling Autoescaping133------------------------134135Autoescaping is the concept of automatically escaping special characters
101 unmodified lines
modified:flask/_compat.py+2 added
26 unmodified lines
27 iteritems = lambda d: iter(d.items())2829 from inspect import getfullargspec as getargspec30 from io import StringIO31 import collections.abc as collections_abc3233 def reraise(tp, value, tb=None):34 if value.__traceback__ is not tb:35 raise value.with_traceback(tb)
11 unmodified lines
47 iteritems = lambda d: d.iteritems()4849 from inspect import getargspec50 from cStringIO import StringIO51 import collections as collections_abc5253 exec('def reraise(tp, value, tb=None):\n raise tp, value, tb')5455 def implements_to_string(cls):
55 unmodified lines
modified:flask/app.py+9 added-8 removed
1676 unmodified lines
16771678 return False16791680 def handle_user_exception(self, e):1681 """This method is called whenever an exception occurs that should be1682 handled. A special case are1683 :class:`~werkzeug.exception.HTTPException`\s which are forwarded by1684 this function to the :meth:`handle_http_exception` method. This1685 function will either return a response value or reraise the1686 exception with the same traceback.1681 """This method is called whenever an exception occurs that1682 should be handled. A special case is :class:`~werkzeug1683 .exceptions.HTTPException` which is forwarded to the1684 :meth:`handle_http_exception` method. This function will either1685 return a response value or reraise the exception with the same1686 traceback.16871688 .. versionchanged:: 1.01689 Key errors raised from request data like ``form`` show the bad1690 key in debug mode rather than a generic bad request message.1689 Key errors raised from request data like ``form`` show the1690 bad key in debug mode rather than a generic bad request1691 message.16921693 .. versionadded:: 0.71694 """1695 exc_type, exc_value, tb = sys.exc_info()
621 unmodified lines
modified:flask/cli.py+4 added-4 removed
331 unmodified lines
332 return rv(environ, start_response)333334335class ScriptInfo(object):336 """Help object to deal with Flask applications. This is usually not336 """Helper object to deal with Flask applications. This is usually not337 necessary to interface with as it's used internally in the dispatching338 to click. In future versions of Flask this object will most likely play339 a bigger role. Typically it's created automatically by the340 :class:`FlaskGroup` but you can also manually create it and pass it
383 unmodified lines
724725 return value726727728@click.command('run', short_help='Runs a development server.')728@click.command('run', short_help='Run a development server.')729@click.option('--host', '-h', default='127.0.0.1',730 help='The interface to bind to.')731@click.option('--port', '-p', default=5000,732 help='The port to bind to.')
43 unmodified lines
776 run_simple(host, port, app, use_reloader=reload, use_debugger=debugger,777 threaded=with_threads, ssl_context=cert)778779780@click.command('shell', short_help='Runs a shell in the app context.')780@click.command('shell', short_help='Run a shell in the app context.')781@with_appcontext782def shell_command():783 """Runs an interactive Python shell in the context of a given783 """Run an interactive Python shell in the context of a given784 Flask application. The application will populate the default785 namespace of this shell according to it's configuration.786787 This is useful for executing small snippets of management code
117 unmodified lines
modified:flask/sessions.py+2 added-2 removed
9 unmodified lines
10"""1112import hashlib13import warnings14from collections import MutableMapping14from datetime import datetime1516from itsdangerous import BadSignature, URLSafeTimedSerializer17from werkzeug.datastructures import CallbackDict1819from flask._compat import collections_abc20from flask.helpers import is_ip, total_seconds21from flask.json.tag import TaggedJSONSerializer222324class SessionMixin(MutableMapping):24class SessionMixin(collections_abc.MutableMapping):25 """Expands a basic dictionary with session attributes."""2627 @property28 def permanent(self):
357 unmodified lines
modified:.appveyor.yml+1 added-1 removed
1 unmodified line
2 global:3 TOXENV: py,codecov45 matrix:6 - PYTHON: C:\Python36-x646 - PYTHON: C:\Python37-x647 - PYTHON: C:\Python27-x6489init:10 - SET PATH=%PYTHON%;%PATH%
16 unmodified lines
modified:.travis.yml+19 added-21 removed
1os: linux2sudo: false2dist: xenial3language: python4python:5 - "3.7"6 - "3.6"7 - "3.5"8 - "3.4"9 - "2.7"10 - nightly11 - pypy3.5-6.012env: TOXENV=py,codecov1314matrix:15 include:7 - python: 3.68 env: TOXENV=py,simplejson,devel,lowest,codecov9 - python: 3.610 env: TOXENV=docs-html11 - python: 3.512 env: TOXENV=py,codecov13 - python: 3.414 env: TOXENV=py,codecov15 - python: 2.716 env: TOXENV=py,simplejson,devel,lowest,codecov17 - python: pypy318 env: TOXENV=py,codecov19 - python: nightly20 env: TOXENV=py16 - env: TOXENV=docs-html17 - env: TOXENV=devel,lowest,codecov18 - os: osx19 language: generic23 env: TOXENV=py3,py2,codecov20 env: TOXENV=py3,codecov21 cache:25 pip: false22 directories:23 - $HOME/Library/Caches/Homebrew24 - $HOME/Library/Caches/pip25 allow_failures:30 - python: pypy326 - python: nightly27 - python: pypy3.5-6.028 - os: osx29 fast_finish: true3031before_install:32 - |33 if [[ $TRAVIS_OS_NAME == 'osx' ]]; then34 brew upgrade python39 brew install python@2;35 export PATH="/usr/local/opt/python/libexec/bin:${PATH}"36 fi3738install:
2 unmodified lines
41script:42 - tox4344cache:50 - pip45 directories:46 - $HOME/.cache/pip47 - $HOME/.cache/pre-commit4849branches:50 only:51 - master55 - /^.*-maintenance$/52 - /^\d+(\.\d+)*-maintenance$/53 - /^\d+(\.\d+)*(\.x)?$/5455notifications:56 email: false
modified:tox.ini+4 added-4 removed
1[tox]2envlist =3 py{36,35,34,27,py}4 py{36,27,py}-simplejson5 py{36,27,py}-devel6 py{36,27,py}-lowest3 py{37,36,35,34,27,py}4 py{37,27,py}-simplejson5 py{37,27,py}-devel6 py{37,27,py}-lowest7 docs-html8 coverage-report910[testenv]
50 unmodified lines