Merge branch '2.0.x'
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 44bc286, 303a1e6 · Browse files · 10 files·+50 added−50 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
10 files+50 added−50 removed
- other:+50 added−50 removed
Provenance
- Commit
0ae0f59- Tree
f491d01- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent 1
44bc286- Parent 2
303a1e6
10 files changed+50 added−50 removed
modified:docs/patterns/sqlite3.rst+3 added-3 removed
111 unmodified lines112 113 Here is how you can use it::114 115 for user in query_db('select * from users'):116- print user['username'], 'has the id', user['user_id']116+ print(user['username'], 'has the id', user['user_id'])117 118 Or if you just want a single result::119 120 user = query_db('select * from users where username = ?',121 [the_username], one=True)122 if user is None:123- print 'No such user'123+ print('No such user')124 else:125- print the_username, 'has the id', user['user_id']125+ print(the_username, 'has the id', user['user_id'])126 127 To pass variable parts to the SQL statement, use a question mark in the128 statement and pass in the arguments as a list. Never directly add them to129 the SQL statement with string formatting because this makes it possible22 unmodified linesmodified:docs/tutorial/deploy.rst+3 added-3 removed
86 unmodified lines87 You can use the following command to output a random secret key:88 89 .. code-block:: none90 91- $ python -c 'import os; print(os.urandom(16))'91+ $ python -c 'import secrets; print(secrets.token_hex())'92 93- b'_5#y2L"F4Q8z\n\xec]/'93+ '192b9bdd22ab9ed4d12e236c78afcb9a393ec15f71bbf5dc987d54727823bcbf'94 95 Create the ``config.py`` file in the instance folder, which the factory96 will read from if it exists. Copy the generated value into it.97 98 .. code-block:: python99 :caption: ``venv/var/flaskr-instance/config.py``100 101- SECRET_KEY = b'_5#y2L"F4Q8z\n\xec]/'101+ SECRET_KEY = '192b9bdd22ab9ed4d12e236c78afcb9a393ec15f71bbf5dc987d54727823bcbf'102 103 You can also set any other necessary configuration here, although104 ``SECRET_KEY`` is the only one needed for Flaskr.105 34 unmodified linesmodified:docs/config.rst+4 added-4 removed
36 unmodified lines37 method::38 39 app.config.update(40 TESTING=True,41- SECRET_KEY=b'_5#y2L"F4Q8z\n\xec]/'41+ SECRET_KEY='192b9bdd22ab9ed4d12e236c78afcb9a393ec15f71bbf5dc987d54727823bcbf'42 )43 44 45 Environment and Debug Features133 unmodified lines179 and can be used for any other security related needs by extensions or your180 application. It should be a long random ``bytes`` or ``str``. For181 example, copy the output of this to your config::182 183- $ python -c 'import os; print(os.urandom(16))'184- b'_5#y2L"F4Q8z\n\xec]/'183+ $ python -c 'import secrets; print(secrets.token_hex())'184+ '192b9bdd22ab9ed4d12e236c78afcb9a393ec15f71bbf5dc987d54727823bcbf'185 186 **Do not reveal the secret key when posting questions or committing code.**187 188 Default: ``None``278 unmodified lines467 468 Here is an example of a configuration file::469 470 # Example configuration471- SECRET_KEY = b'_5#y2L"F4Q8z\n\xec]/'471+ SECRET_KEY = '192b9bdd22ab9ed4d12e236c78afcb9a393ec15f71bbf5dc987d54727823bcbf'472 473 Make sure to load the configuration very early on, so that extensions have474 the ability to access the configuration when starting up. There are other475 methods on the config object as well to load from individual files. For a293 unmodified linesmodified:docs/quickstart.rst+2 added-2 removed
845 unmodified lines846 ways to generate pretty random data based on a cryptographic random847 generator. Use the following command to quickly generate a value for848 :attr:`Flask.secret_key` (or :data:`SECRET_KEY`)::849 850- $ python -c 'import os; print(os.urandom(16))'851- b'_5#y2L"F4Q8z\n\xec]/'850+ $ python -c 'import secrets; print(secrets.token_hex())'851+ '192b9bdd22ab9ed4d12e236c78afcb9a393ec15f71bbf5dc987d54727823bcbf'852 853 A note on cookie-based sessions: Flask will take the values you put into the854 session object and serialize them into a cookie. If you are finding some855 values do not persist across requests, cookies are indeed enabled, and you are83 unmodified linesmodified:docs/signals.rst+1 added-1 removed
175 unmodified lines176 from flask import template_rendered177 178 @template_rendered.connect_via(app)179 def when_template_rendered(sender, template, context, **extra):180- print f'Template {template.name} is rendered with {context}'180+ print(f'Template {template.name} is rendered with {context}')181 182 Core Signals183 ------------184 4 unmodified linesmodified:requirements/dev.txt+20 added-20 removed
1 #2-# This file is autogenerated by pip-compile with python 3.92+# This file is autogenerated by pip-compile with python 3.103 # To update, run:4 #5 # pip-compile requirements/dev.in6 #8 unmodified lines15 backports.entry-points-selectable==1.1.016 # via virtualenv17 blinker==1.418 # via -r requirements/tests.in19-certifi==2021.5.3019+certifi==2021.10.820 # via requests21-cffi==1.14.621+cffi==1.15.022 # via cryptography23 cfgv==3.3.124 # via pre-commit25-charset-normalizer==2.0.625+charset-normalizer==2.0.726 # via requests27-click==8.0.127+click==8.0.328 # via pip-tools29 cryptography==35.0.030 # via -r requirements/typing.in31 distlib==0.3.31 unmodified line33 docutils==0.1634 # via35 # sphinx36 # sphinx-tabs37-filelock==3.2.037+filelock==3.3.238 # via39 # tox40 # virtualenv41 greenlet==1.1.242 # via -r requirements/tests.in43-identify==2.2.1543+identify==2.3.344 # via pre-commit45-idna==3.245+idna==3.346 # via requests47 imagesize==1.2.048 # via sphinx49 iniconfig==1.1.150 # via pytest51-jinja2==3.0.151+jinja2==3.0.252 # via sphinx53 markupsafe==2.0.154 # via jinja255 mypy==0.9101 unmodified line57 mypy-extensions==0.4.358 # via mypy59 nodeenv==1.6.060 # via pre-commit61-packaging==21.061+packaging==21.262 # via63 # pallets-sphinx-themes64 # pytest65 # sphinx66 # tox67 pallets-sphinx-themes==2.0.168 # via -r requirements/docs.in69-pep517==0.11.069+pep517==0.12.070 # via pip-tools71-pip-tools==6.3.071+pip-tools==6.4.072 # via -r requirements/dev.in73 platformdirs==2.4.074 # via virtualenv75 pluggy==1.0.015 unmodified lines91 pyparsing==2.4.792 # via packaging93 pytest==6.2.594 # via -r requirements/tests.in95-python-dotenv==0.19.095+python-dotenv==0.19.196 # via -r requirements/tests.in97-pytz==2021.197+pytz==2021.398 # via babel99-pyyaml==5.4.199+pyyaml==6.0100 # via pre-commit101 requests==2.26.0102 # via sphinx103 six==1.16.032 unmodified lines136 # mypy137 # pre-commit138 # pytest139 # tox140-tomli==1.2.1140+tomli==1.2.2141 # via pep517142 tox==3.24.4143 # via -r requirements/dev.in144-types-contextvars==0.1.4144+types-contextvars==2.4.0145 # via -r requirements/typing.in146-types-dataclasses==0.1.7146+types-dataclasses==0.6.1147 # via -r requirements/typing.in148-types-setuptools==57.4.0148+types-setuptools==57.4.2149 # via -r requirements/typing.in150 typing-extensions==3.10.0.2151 # via mypy152 urllib3==1.26.7153 # via requests154-virtualenv==20.8.1154+virtualenv==20.10.0155 # via156 # pre-commit157 # tox158 wheel==0.37.05 unmodified linesmodified:requirements/docs.txt+7 added-7 removed
1 #2-# This file is autogenerated by pip-compile with python 3.92+# This file is autogenerated by pip-compile with python 3.103 # To update, run:4 #5 # pip-compile requirements/docs.in6 #7 alabaster==0.7.128 # via sphinx9 babel==2.9.110 # via sphinx11-certifi==2021.5.3011+certifi==2021.10.812 # via requests13-charset-normalizer==2.0.613+charset-normalizer==2.0.714 # via requests15 docutils==0.1616 # via17 # sphinx18 # sphinx-tabs19-idna==3.219+idna==3.320 # via requests21 imagesize==1.2.022 # via sphinx23-jinja2==3.0.123+jinja2==3.0.224 # via sphinx25 markupsafe==2.0.126 # via jinja227-packaging==21.027+packaging==21.228 # via29 # pallets-sphinx-themes30 # sphinx31 pallets-sphinx-themes==2.0.13 unmodified lines35 # sphinx36 # sphinx-tabs37 pyparsing==2.4.738 # via packaging39-pytz==2021.139+pytz==2021.340 # via babel41 requests==2.26.042 # via sphinx43 snowballstemmer==2.1.031 unmodified linesmodified:requirements/tests.txt+3 added-3 removed
1 #2-# This file is autogenerated by pip-compile with python 3.92+# This file is autogenerated by pip-compile with python 3.103 # To update, run:4 #5 # pip-compile requirements/tests.in6 #6 unmodified lines13 greenlet==1.1.214 # via -r requirements/tests.in15 iniconfig==1.1.116 # via pytest17-packaging==21.017+packaging==21.218 # via pytest19 pluggy==1.0.020 # via pytest21 py==1.10.01 unmodified line23 pyparsing==2.4.724 # via packaging25 pytest==6.2.526 # via -r requirements/tests.in27-python-dotenv==0.19.027+python-dotenv==0.19.128 # via -r requirements/tests.in29 toml==0.10.230 # via pytestmodified:requirements/typing.txt+5 added-5 removed
1 #2-# This file is autogenerated by pip-compile with python 3.92+# This file is autogenerated by pip-compile with python 3.103 # To update, run:4 #5 # pip-compile requirements/typing.in6 #7-cffi==1.14.67+cffi==1.15.08 # via cryptography9 cryptography==35.0.010 # via -r requirements/typing.in11 mypy==0.9103 unmodified lines15 pycparser==2.2016 # via cffi17 toml==0.10.218 # via mypy19-types-contextvars==0.1.419+types-contextvars==2.4.020 # via -r requirements/typing.in21-types-dataclasses==0.1.721+types-dataclasses==0.6.122 # via -r requirements/typing.in23-types-setuptools==57.4.023+types-setuptools==57.4.224 # via -r requirements/typing.in25 typing-extensions==3.10.0.226 # via mypymodified:.pre-commit-config.yaml+2 added-2 removed
12 unmodified lines13 name: Reorder Python imports (src, tests)14 files: "^(?!examples/)"15 args: ["--application-directories", "src"]16 - repo: https://github.com/psf/black17- rev: 21.9b017+ rev: 21.10b018 hooks:19 - id: black20 - repo: https://github.com/PyCQA/flake821- rev: 3.9.221+ rev: 4.0.122 hooks:23 - id: flake824 additional_dependencies:25 - flake8-bugbear7 unmodified lines