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
Provenance
- Commit
3b45b82- Tree
17a3c2c- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent 1
b78ebac- Parent 2
a656025
13 files changed+68 added−57 removed
modified:docs/tutorial/blog.rst+1 added-1 removed
312 unmodified lines313 ------314 315 The delete view doesn't have its own template, the delete button is part316 of ``update.html`` and posts to the ``/<id>/delete`` URL. Since there317-is no template, it will only handle the ``POST`` method then redirect317+is no template, it will only handle the ``POST`` method and then redirect318 to the ``index`` view.319 320 .. code-block:: python321 :caption: ``flaskr/blog.py``15 unmodified linesmodified:docs/tutorial/database.rst+1 added-1 removed
147 unmodified lines148 Register with the Application149 -----------------------------150 151 The ``close_db`` and ``init_db_command`` functions need to be registered152-with the application instance, otherwise they won't be used by the152+with the application instance; otherwise, they won't be used by the153 application. However, since you're using a factory function, that154 instance isn't available when writing the functions. Instead, write a155 function that takes an application and does the registration.156 57 unmodified linesmodified:docs/api.rst+4 added-4 removed
310 unmodified lines311 will have that method called and then the return value is serialized312 as string.313 314 The :func:`~htmlsafe_dumps` function of this json module is also available315-as filter called ``|tojson`` in Jinja2. Note that inside ``script``316-tags no escaping must take place, so make sure to disable escaping317-with ``|safe`` if you intend to use it inside ``script`` tags unless318-you are using Flask 0.10 which implies that:315+as a filter called ``|tojson`` in Jinja2. Note that in versions of Flask prior316+to 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, this318+happens automatically (but it's harmless to include ``|safe`` anyway).319 320 .. sourcecode:: html+jinja321 322 <script type=text/javascript>511 unmodified linesmodified:docs/blueprints.rst+4 added-3 removed
73 unmodified lines74 except TemplateNotFound:75 abort(404)76 77 When you bind a function with the help of the ``@simple_page.route``78-decorator the blueprint will record the intention of registering the79-function `show` on the application when it's later registered.78+decorator, the blueprint will record the intention of registering the79+function ``show`` on the application when it's later registered.80 Additionally it will prefix the endpoint of the function with the81 name of the blueprint which was given to the :class:`Blueprint`82-constructor (in this case also ``simple_page``).82+constructor (in this case also ``simple_page``). The blueprint's name83+does not modify the URL, only the endpoint.84 85 Registering Blueprints86 ----------------------87 190 unmodified linesmodified:docs/installation.rst+3 added-3 removed
89 unmodified lines90 .. code-block:: bat91 92 $ py -3 -m venv venv93 94-If you needed to install virtualenv because you are on an older version of95-Python, use the following command instead:94+If you needed to install virtualenv because you are using Python 2, use95+the following command instead:96 97 .. code-block:: sh98 99- $ virtualenv venv99+ $ python2 -m virtualenv venv100 101 On Windows:102 103 .. code-block:: bat83 unmodified linesmodified:docs/templating.rst+14 added-5 removed
108 unmodified lines109 This function converts the given object into JSON representation. This110 is for example very helpful if you try to generate JavaScript on the111 fly.112 113- 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:116-113 .. sourcecode:: html+jinja114 115 <script type=text/javascript>120- doSomethingWith({{ user.username|tojson|safe }});116+ doSomethingWith({{ user.username|tojson }});117 </script>118 119+ It is also safe to use the output of `|tojson` in a *single-quoted* HTML120+ attribute:121+122+ .. sourcecode:: html+jinja123+124+ <button onclick='doSomethingWith({{ user.username|tojson }})'>125+ Click me126+ </button>127+128+ 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.131+132 Controlling Autoescaping133 ------------------------134 135 Autoescaping is the concept of automatically escaping special characters101 unmodified linesmodified:flask/_compat.py+2 added
26 unmodified lines27 iteritems = lambda d: iter(d.items())28 29 from inspect import getfullargspec as getargspec30 from io import StringIO31+ import collections.abc as collections_abc32 33 def reraise(tp, value, tb=None):34 if value.__traceback__ is not tb:35 raise value.with_traceback(tb)11 unmodified lines47 iteritems = lambda d: d.iteritems()48 49 from inspect import getargspec50 from cStringIO import StringIO51+ import collections as collections_abc52 53 exec('def reraise(tp, value, tb=None):\n raise tp, value, tb')54 55 def implements_to_string(cls):55 unmodified linesmodified:flask/app.py+9 added-8 removed
1676 unmodified lines1677 1678 return False1679 1680 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.1687 1688 .. 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.1692 1693 .. versionadded:: 0.71694 """1695 exc_type, exc_value, tb = sys.exc_info()621 unmodified linesmodified:flask/cli.py+4 added-4 removed
331 unmodified lines332 return rv(environ, start_response)333 334 335 class 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 it383 unmodified lines724 725 return value726 727 728-@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 lines776 run_simple(host, port, app, use_reloader=reload, use_debugger=debugger,777 threaded=with_threads, ssl_context=cert)778 779 780-@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_appcontext782 def 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.786 787 This is useful for executing small snippets of management code117 unmodified linesmodified:flask/sessions.py+2 added-2 removed
9 unmodified lines10 """11 12 import hashlib13 import warnings14-from collections import MutableMapping14 from datetime import datetime15 16 from itsdangerous import BadSignature, URLSafeTimedSerializer17 from werkzeug.datastructures import CallbackDict18 19+from flask._compat import collections_abc20 from flask.helpers import is_ip, total_seconds21 from flask.json.tag import TaggedJSONSerializer22 23 24-class SessionMixin(MutableMapping):24+class SessionMixin(collections_abc.MutableMapping):25 """Expands a basic dictionary with session attributes."""26 27 @property28 def permanent(self):357 unmodified linesmodified:.appveyor.yml+1 added-1 removed
1 unmodified line2 global:3 TOXENV: py,codecov4 5 matrix:6- - PYTHON: C:\Python36-x646+ - PYTHON: C:\Python37-x647 - PYTHON: C:\Python27-x648 9 init:10 - SET PATH=%PYTHON%;%PATH%16 unmodified linesmodified:.travis.yml+19 added-21 removed
1 os: linux2-sudo: false2+dist: xenial3 language: python4+python:5+ - "3.7"6+ - "3.6"7+ - "3.5"8+ - "3.4"9+ - "2.7"10+ - nightly11+ - pypy3.5-6.012+env: TOXENV=py,codecov13 14 matrix: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: true30 31 before_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 fi37 38 install:2 unmodified lines41 script:42 - tox43 44 cache:50- - pip45+ directories:46+ - $HOME/.cache/pip47+ - $HOME/.cache/pre-commit48 49 branches:50 only:51 - master55- - /^.*-maintenance$/52+ - /^\d+(\.\d+)*-maintenance$/53+ - /^\d+(\.\d+)*(\.x)?$/54 55 notifications:56 email: falsemodified:tox.ini+4 added-4 removed
1 [tox]2 envlist =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-report9 10 [testenv]50 unmodified lines