docstring_tokens
stringlengths
0
76.5k
code_tokens
stringlengths
75
1.81M
label_window
listlengths
4
2.12k
html_url
stringlengths
74
116
file_name
stringlengths
3
311
result = set(self.app.jinja_loader.list_templates())
<mask> # fall back to application loader if module failed <mask> return self.app.jinja_loader.get_source(environment, template) <mask> <mask> def list_templates(self): <mask> result = self.app.jinja_loader.list_templates() <mask> for name, module in self.app.modules.iteritems(...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a06cd0a64418f2aafafb0a574c64c2ea5f3e9239
flask/templating.py
result.add('%s/%s' % (name, template)) for name, blueprint in self.app.blueprints.iteritems(): if blueprint.jinja_loader is not None: for template in blueprint.jinja_loader.list_templates(): result.add('%s:%s' % (name, template)) retu...
<mask> result = self.app.jinja_loader.list_templates() <mask> for name, module in self.app.modules.iteritems(): <mask> if module.jinja_loader is not None: <mask> for template in module.jinja_loader.list_templates(): <mask> result.append('%s/%s' % (nam...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a06cd0a64418f2aafafb0a574c64c2ea5f3e9239
flask/templating.py
if template_name[:1] == ':': template_name = ctx.request.blueprint + template_name
<mask> ctx = _request_ctx_stack.top <mask> ctx.app.update_template_context(context) <mask> return _render(ctx.app.jinja_env.get_template(template_name), <mask> context, ctx.app) <mask> <mask> <mask> def render_template_string(source, **context): </s> Started work on implementing...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a06cd0a64418f2aafafb0a574c64c2ea5f3e9239
flask/templating.py
if self.url_rule and \ ':' not in self.url_rule.endpoint and \ '.' in self.url_rule.endpoint:
<mask> <mask> @property <mask> def module(self): <mask> """The name of the current module""" <mask> if self.url_rule and '.' in self.url_rule.endpoint: <mask> return self.url_rule.endpoint.rsplit('.', 1)[0] <mask> <mask> @cached_property <mask> def json(self): <ma...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a06cd0a64418f2aafafb0a574c64c2ea5f3e9239
flask/wrappers.py
@property def blueprint(self): """The name of the current blueprint""" if self.url_rule and ':' in self.url_rule.endpoint: return self.url_rule.endpoint.split(':', 1)[0]
<mask> '.' in self.url_rule.endpoint: <mask> return self.url_rule.endpoint.rsplit('.', 1)[0] <mask> <mask> @cached_property <mask> def json(self): <mask> """If the mimetype is `application/json` this will contain the <mask> parsed JSON data. <mask> """ <m...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a06cd0a64418f2aafafb0a574c64c2ea5f3e9239
flask/wrappers.py
app.debug = True
<mask> assert 'internal server error' == rv.data <mask> <mask> def test_templates_and_static(self): <mask> app = moduleapp <mask> c = app.test_client() <mask> <mask> rv = c.get('/') <mask> assert rv.data == 'Hello from the Frontend' </s> Started work on implementin...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a06cd0a64418f2aafafb0a574c64c2ea5f3e9239
tests/flask_tests.py
- master
<mask> trigger: <mask> - 'master' <mask> - '*.x' <mask> <mask> jobs: <mask> - job: Tests <mask> variables: </s> drop support for Python 2.7 and 3.5 </s> remove jobs: - job: Tests variables: vmImage: 'ubuntu-latest' python.version: '3.8' TOXENV: 'py,coverage-ci' hasTestRe...
[ "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0a61acdecd925cf2a1ffe5fb7acd27c1695f1d8
.azure-pipelines.yml
variables: vmImage: ubuntu-latest python.version: '3.8' TOXENV: py
<mask> trigger: <mask> - 'master' <mask> - '*.x' <mask> <mask> jobs: <mask> - job: Tests <mask> variables: <mask> vmImage: 'ubuntu-latest' <mask> python.version: '3.8' <mask> TOXENV: 'py,coverage-ci' <mask> hasTestResults: 'true' <mask> <mask> strategy: <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0a61acdecd925cf2a1ffe5fb7acd27c1695f1d8
.azure-pipelines.yml
strategy: matrix: Linux:
<mask> python.version: '3.8' <mask> TOXENV: 'py,coverage-ci' <mask> hasTestResults: 'true' <mask> <mask> strategy: <mask> matrix: <mask> Python 3.8 Linux: <mask> vmImage: 'ubuntu-latest' <mask> Python 3.8 Windows: <mask> vmImage: 'windows-latest...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "re...
https://github.com/pallets/flask/commit/a0a61acdecd925cf2a1ffe5fb7acd27c1695f1d8
.azure-pipelines.yml
Windows: vmImage: windows-latest Mac: vmImage: macos-latest Python 3.7: python.version: '3.7' Python 3.6: python.version: '3.6' PyPy 3: python.version: pypy3 Version Range: TOXENV: 'devel,lowest' Docs: TOXENV: docs Style: TOXENV: style poo...
<mask> # Use a container since Azure Pipelines may not have the latest build. <mask> - job: FlaskOnNightly <mask> pool: <mask> vmImage: ubuntu-latest <mask> container: python:rc-stretch <mask> steps: <mask> - script: | <mask> echo "##vso[task.prependPath]$HOME/.local/bin" ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace" ]
https://github.com/pallets/flask/commit/a0a61acdecd925cf2a1ffe5fb7acd27c1695f1d8
.azure-pipelines.yml
Version 2.0.0
<mask> .. currentmodule:: flask <mask> <mask> Version 1.2.0 <mask> ------------- <mask> <mask> Unreleased <mask> <mask> - Add :meth:`sessions.SessionInterface.get_cookie_name` to allow </s> drop support for Python 2.7 and 3.5 </s> remove container: python:rc-stretch steps: - script: | ...
[ "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0a61acdecd925cf2a1ffe5fb7acd27c1695f1d8
CHANGES.rst
- Drop support for Python 2 and 3.5.
<mask> Unreleased <mask> <mask> - Add :meth:`sessions.SessionInterface.get_cookie_name` to allow <mask> setting the session cookie name dynamically. :pr:`3369` <mask> - Add :meth:`Config.from_file` to load config using arbitrary file <mask> loaders, such as ``toml.load`` or ``json.load``. <mask> ...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0a61acdecd925cf2a1ffe5fb7acd27c1695f1d8
CHANGES.rst
<mask> [bdist_wheel] <mask> universal = true <mask> <mask> [tool:pytest] <mask> testpaths = tests <mask> <mask> [coverage:run] <mask> branch = True </s> drop support for Python 2.7 and 3.5 </s> remove src/flask .tox/*/lib/python*/site-packages/flask .tox/*/site-packages/flask </s> add src ...
[ "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0a61acdecd925cf2a1ffe5fb7acd27c1695f1d8
setup.cfg
filterwarnings = error
<mask> [tool:pytest] <mask> testpaths = tests <mask> <mask> [coverage:run] <mask> branch = True <mask> source = <mask> flask <mask> tests </s> drop support for Python 2.7 and 3.5 </s> remove [bdist_wheel] universal = true </s> add </s> remove src/flask .tox/*/lib/python*/site-packages/flask...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0a61acdecd925cf2a1ffe5fb7acd27c1695f1d8
setup.cfg
src */site-packages
<mask> tests <mask> <mask> [coverage:paths] <mask> source = <mask> src/flask <mask> .tox/*/lib/python*/site-packages/flask <mask> .tox/*/site-packages/flask <mask> <mask> [flake8] <mask> # B = bugbear <mask> # E = pycodestyle errors <mask> # F = flake8 pyflakes </s> drop support for Pytho...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0a61acdecd925cf2a1ffe5fb7acd27c1695f1d8
setup.cfg
<mask> "Intended Audience :: Developers", <mask> "License :: OSI Approved :: BSD License", <mask> "Operating System :: OS Independent", <mask> "Programming Language :: Python", <mask> "Programming Language :: Python :: 2", <mask> "Programming Language :: Python :: 2...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0a61acdecd925cf2a1ffe5fb7acd27c1695f1d8
setup.py
python_requires=">=3.6",
<mask> ], <mask> packages=find_packages("src"), <mask> package_dir={"": "src"}, <mask> include_package_data=True, <mask> python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*", <mask> install_requires=[ <mask> "Werkzeug>=0.15", <mask> "Jinja2>=2.10.1", <mas...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0a61acdecd925cf2a1ffe5fb7acd27c1695f1d8
setup.py
__version__ = "2.0.0.dev"
<mask> from .signals import template_rendered <mask> from .templating import render_template <mask> from .templating import render_template_string <mask> <mask> __version__ = "1.2.0.dev" </s> drop support for Python 2.7 and 3.5 </s> remove deps = -r docs/requirements.txt </s> add deps = -r docs/requirements...
[ "keep", "keep", "keep", "keep", "replace" ]
https://github.com/pallets/flask/commit/a0a61acdecd925cf2a1ffe5fb7acd27c1695f1d8
src/flask/__init__.py
@pytest.mark.xfail(reason="weird interaction with tox")
<mask> app = flask.Flask(__name__, instance_path=str(modules_tmpdir)) <mask> assert app.instance_path == str(modules_tmpdir) <mask> <mask> <mask> @pytest.mark.xfail(reason="TODO: weird interaction with tox") <mask> def test_main_module_paths(modules_tmpdir, purge_module): <mask> app = modules_tmpdi...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0a61acdecd925cf2a1ffe5fb7acd27c1695f1d8
tests/test_instance_config.py
@pytest.mark.xfail(reason="weird interaction with tox")
<mask> <mask> <mask> def test_uninstalled_module_paths(modules_tmpdir, purge_module): <mask> app = modules_tmpdir.join("config_module_app.py").write( <mask> "import os\n" <mask> "import flask\n" </s> drop support for Python 2.7 and 3.5 </s> remove @pytest.mark.xfail(reason="TODO: weird inte...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0a61acdecd925cf2a1ffe5fb7acd27c1695f1d8
tests/test_instance_config.py
@pytest.mark.xfail(reason="weird interaction with tox")
<mask> assert app.instance_path == str(modules_tmpdir.join("instance")) <mask> <mask> <mask> def test_uninstalled_package_paths(modules_tmpdir, purge_module): <mask> app = modules_tmpdir.mkdir("config_package_app") <mask> init = app.join("__init__.py") <mask> init.write( <mask> "import...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0a61acdecd925cf2a1ffe5fb7acd27c1695f1d8
tests/test_instance_config.py
py{38,37,36,py3}
<mask> [tox] <mask> envlist = <mask> py{38,37,36,35,27,py3,py} <mask> py38-{simplejson,devel,lowest} <mask> docs <mask> coverage <mask> skip_missing_interpreters = true <mask> </s> drop support for Python 2.7 and 3.5 </s> remove coverage </s> add </s> remove passenv = LANG </s> add </s...
[ "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0a61acdecd925cf2a1ffe5fb7acd27c1695f1d8
tox.ini
style
<mask> envlist = <mask> py{38,37,36,py3} <mask> py38-{simplejson,devel,lowest} <mask> docs <mask> skip_missing_interpreters = true <mask> <mask> [testenv] <mask> deps = <mask> pytest </s> drop support for Python 2.7 and 3.5 </s> remove py{38,37,36,35,27,py3,py} </s> add py{38,37,36,p...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0a61acdecd925cf2a1ffe5fb7acd27c1695f1d8
tox.ini
<mask> envlist = <mask> py{38,37,36,35,27,py3,py} <mask> py38-{simplejson,devel,lowest} <mask> docs <mask> coverage <mask> skip_missing_interpreters = true <mask> <mask> [testenv] <mask> passenv = LANG <mask> deps = </s> drop support for Python 2.7 and 3.5 </s> remove py{38,37,36,35,27,p...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0a61acdecd925cf2a1ffe5fb7acd27c1695f1d8
tox.ini
<mask> coverage <mask> skip_missing_interpreters = true <mask> <mask> [testenv] <mask> passenv = LANG <mask> deps = <mask> pytest <mask> coverage <mask> greenlet <mask> blinker </s> drop support for Python 2.7 and 3.5 </s> remove coverage </s> add </s> remove coverage </s> add...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0a61acdecd925cf2a1ffe5fb7acd27c1695f1d8
tox.ini
<mask> [testenv] <mask> passenv = LANG <mask> deps = <mask> pytest <mask> coverage <mask> greenlet <mask> blinker <mask> python-dotenv <mask> <mask> lowest: Werkzeug==0.15.5 </s> drop support for Python 2.7 and 3.5 </s> remove passenv = LANG </s> add </s> remove coverage </s> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0a61acdecd925cf2a1ffe5fb7acd27c1695f1d8
tox.ini
<mask> <mask> simplejson: simplejson <mask> <mask> commands = <mask> # the examples need to be installed to test successfully <mask> pip install -q -e examples/tutorial[test] <mask> pip install -q -e examples/javascript[test] <mask> <mask> # pytest-cov doesn't seem to play nice with -p ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0a61acdecd925cf2a1ffe5fb7acd27c1695f1d8
tox.ini
pytest --tb=short --basetemp={envtmpdir} {posargs:tests examples}
<mask> # the examples need to be installed to test successfully <mask> pip install -q -e examples/tutorial[test] <mask> pip install -q -e examples/javascript[test] <mask> <mask> # pytest-cov doesn't seem to play nice with -p <mask> coverage run -p -m pytest --tb=short -Werror {posargs:tests e...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0a61acdecd925cf2a1ffe5fb7acd27c1695f1d8
tox.ini
deps = -r docs/requirements.txt
<mask> skip_install = true <mask> commands = pre-commit run --all-files --show-diff-on-failure <mask> <mask> [testenv:docs] <mask> deps = <mask> -r docs/requirements.txt <mask> commands = sphinx-build -W -b html -d {envtmpdir}/doctrees docs {envtmpdir}/html <mask> <mask> [testenv:coverage] <mask> deps =...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0a61acdecd925cf2a1ffe5fb7acd27c1695f1d8
tox.ini
<mask> [testenv:docs] <mask> deps = <mask> -r docs/requirements.txt <mask> commands = sphinx-build -W -b html -d {envtmpdir}/doctrees docs {envtmpdir}/html <mask> <mask> [testenv:coverage] <mask> deps = coverage <mask> skip_install = true <mask> commands = <mask> coverage combine <mask> coverage...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace" ]
https://github.com/pallets/flask/commit/a0a61acdecd925cf2a1ffe5fb7acd27c1695f1d8
tox.ini
- ``flask --version`` outputs Werkzeug's version and simplifies the Python version. (`#2825`_)
<mask> - Allow custom CLIs using ``FlaskGroup`` to set the debug flag without <mask> it always being overwritten based on environment variables. (`#2765`_) <mask> <mask> .. _#2766: https://github.com/pallets/flask/issues/2766 <mask> .. _#2765: https://github.com/pallets/flask/pull/2765 <mask> .. _#2825: ht...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0ccc477800737d9907ab772bb1bba25f164fefb
CHANGES.rst
.. _#2825: https://github.com/pallets/flask/pull/2825
<mask> Python version. (`#2825`_) <mask> <mask> .. _#2766: https://github.com/pallets/flask/issues/2766 <mask> .. _#2765: https://github.com/pallets/flask/pull/2765 <mask> <mask> <mask> Version 1.0.2 <mask> ------------- <mask> <mask> Released on May 2nd 2018 </s> clean up flask --version code </s> r...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0ccc477800737d9907ab772bb1bba25f164fefb
CHANGES.rst
import platform
<mask> <mask> import ast <mask> import inspect <mask> import os <mask> import re <mask> import ssl <mask> import sys <mask> import traceback <mask> from functools import update_wrapper <mask> from operator import attrgetter </s> clean up flask --version code </s> remove import werkzeug </s> add </s> remov...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0ccc477800737d9907ab772bb1bba25f164fefb
flask/cli.py
<mask> import traceback <mask> from functools import update_wrapper <mask> from operator import attrgetter <mask> from threading import Lock, Thread <mask> import werkzeug <mask> <mask> import click <mask> from werkzeug.utils import import_string <mask> <mask> from . import __version__ </s> clean up flask ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0ccc477800737d9907ab772bb1bba25f164fefb
flask/cli.py
import werkzeug message = ( 'Python %(python)s\n' 'Flask %(flask)s\n' 'Werkzeug %(werkzeug)s' )
<mask> <mask> def get_version(ctx, param, value): <mask> if not value or ctx.resilient_parsing: <mask> return <mask> message = 'Python %(python_version)s\nFlask %(version)s\nWerkzeug %(werkzeug_version)s' <mask> click.echo(message % { <mask> 'version': __version__, <mask> 'p...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0ccc477800737d9907ab772bb1bba25f164fefb
flask/cli.py
'python': platform.python_version(), 'flask': __version__, 'werkzeug': werkzeug.__version__,
<mask> if not value or ctx.resilient_parsing: <mask> return <mask> message = 'Python %(python_version)s\nFlask %(version)s\nWerkzeug %(werkzeug_version)s' <mask> click.echo(message % { <mask> 'version': __version__, <mask> 'python_version': sys.version, <mask> 'werkzeu...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0ccc477800737d9907ab772bb1bba25f164fefb
flask/cli.py
from flask import __version__ as flask_version from werkzeug import __version__ as werkzeug_version from platform import python_version
<mask> ) <mask> <mask> <mask> def test_get_version(test_apps, capsys): <mask> """Test of get_version.""" <mask> from flask import __version__ as flask_ver <mask> from sys import version as py_ver <mask> <mask> class MockCtx(object): <mask> resilient_parsing = False <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0ccc477800737d9907ab772bb1bba25f164fefb
tests/test_cli.py
assert "Python " + python_version() in out assert "Flask " + flask_version in out assert "Werkzeug " + werkzeug_version in out
<mask> <mask> ctx = MockCtx() <mask> get_version(ctx, None, "test") <mask> out, err = capsys.readouterr() <mask> assert flask_ver in out <mask> assert py_ver in out <mask> <mask> <mask> def test_scriptinfo(test_apps, monkeypatch): <mask> """Test of ScriptInfo.""" <mask> obj = S...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a0ccc477800737d9907ab772bb1bba25f164fefb
tests/test_cli.py
- Fixed an infinite redirect issue with blueprints.
<mask> <mask> Bugfix release, release date to be decided. <mask> <mask> - Added missing future import that broke 2.5 compatibility. <mask> <mask> Version 0.7 <mask> ----------- <mask> <mask> Released on June 28th 2011, codename Grappa <mask> </s> Worked around a werkzeug bug with redirects
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a101cfc35be437ad0e4f56da0d92f14c27abda67
CHANGES
# due to a werkzeug bug we need to make sure that the defaults are # None if they are an empty dictionary. This should not be necessary # with Werkzeug 0.7 options['defaults'] = options.get('defaults') or None
<mask> provide_automatic_options = False <mask> if 'OPTIONS' not in methods: <mask> methods = tuple(methods) + ('OPTIONS',) <mask> provide_automatic_options = True <mask> rule = self.url_rule_class(rule, methods=methods, **options) <mask> rule.provide_automa...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a101cfc35be437ad0e4f56da0d92f14c27abda67
flask/app.py
def test_empty_url_defaults(self): bp = flask.Blueprint('bp', __name__) @bp.route('/', defaults={'page': 1}) @bp.route('/page/<int:page>') def something(page): return str(page) app = flask.Flask(__name__) app.register_blueprint(bp) c = app.test_...
<mask> self.assertEqual(c.get('/fe').data.strip(), '/be') <mask> self.assertEqual(c.get('/fe2').data.strip(), '/fe') <mask> self.assertEqual(c.get('/be').data.strip(), '/fe') <mask> <mask> <mask> class SendfileTestCase(unittest.TestCase): <mask> <mask> def test_send_file_regular(s...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a101cfc35be437ad0e4f56da0d92f14c27abda67
tests/flask_tests.py
lowest: Click==4.0
<mask> lowest: Jinja2==2.4 <mask> lowest: itsdangerous==0.21 <mask> lowest: blinker==1.0 <mask> <mask> release: blinker <mask> </s> add lowest click version to tox add devel click version to tox add devel markupsafe version to tox
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a11212377d74a48591dda7015c9208048d34caa3
tox.ini
devel: git+https://github.com/pallets/markupsafe.git
<mask> <mask> release: blinker <mask> <mask> devel: git+https://github.com/pallets/werkzeug.git <mask> devel: git+https://github.com/pallets/jinja.git <mask> devel: git+https://github.com/pallets/itsdangerous.git <mask> devel: git+https://github.com/pallets/click.git <mask> devel: git+...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a11212377d74a48591dda7015c9208048d34caa3
tox.ini
devel: git+https://github.com/pallets/click.git
<mask> devel: git+https://github.com/pallets/jinja.git <mask> devel: git+https://github.com/pallets/itsdangerous.git <mask> devel: git+https://github.com/jek/blinker.git <mask> <mask> simplejson: simplejson <mask> <mask> [testenv:docs] </s> add lowest click version to tox add devel click versi...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a11212377d74a48591dda7015c9208048d34caa3
tox.ini
.. py:data:: SESSION_COOKIE_SAMESITE Browser will only send cookies to the domain that created them. There are two possible values for the same-site attribute: "Strict" and "Lax" If set to "None", the samesite flag is not set. Default: ``None``
<mask> <mask> Default: ``False`` <mask> <mask> .. py:data:: PERMANENT_SESSION_LIFETIME <mask> <mask> If ``session.permanent`` is true, the cookie's expiration will be set this <mask> number of seconds in the future. Can either be a <mask> :class:`datetime.timedelta` or an ``int``. </s> New F...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a1d9ebe4abebdb824aa9a397b001de5f9130e7a3
docs/config.rst
domain that created them. There are two possible values for the same-site attribute: "Strict" and "Lax"
<mask> - ``Secure`` limits cookies to HTTPS traffic only. <mask> - ``HttpOnly`` protects the contents of cookies from being read with <mask> JavaScript. <mask> - ``SameSite`` ensures that cookies can only be requested from the same <mask> domain that created them. It is not supported by Flask yet. <mask> <m...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a1d9ebe4abebdb824aa9a397b001de5f9130e7a3
docs/security.rst
SESSION_COOKIE_SAMESITE='Strict'
<mask> app.config.update( <mask> SESSION_COOKIE_SECURE=True, <mask> SESSION_COOKIE_HTTPONLY=True, <mask> ) <mask> <mask> response.set_cookie('username', 'flask', secure=True, httponly=True, samesite='Strict') <mask> <mask> Specifying ``Expires`` or ``Max-Age`` options, will remove t...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a1d9ebe4abebdb824aa9a397b001de5f9130e7a3
docs/security.rst
response.set_cookie('username', 'flask', secure=True, httponly=True, samesite='Strict')
<mask> SESSION_COOKIE_SECURE=True, <mask> SESSION_COOKIE_HTTPONLY=True, <mask> ) <mask> <mask> response.set_cookie('username', 'flask', secure=True, httponly=True) <mask> <mask> Specifying ``Expires`` or ``Max-Age`` options, will remove the cookie after <mask> the given time, or the cur...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a1d9ebe4abebdb824aa9a397b001de5f9130e7a3
docs/security.rst
'SESSION_COOKIE_SAMESITE': None,
<mask> 'SESSION_COOKIE_HTTPONLY': True, <mask> 'SESSION_COOKIE_SECURE': False, <mask> 'SESSION_REFRESH_EACH_REQUEST': True, <mask> 'MAX_CONTENT_LENGTH': None, <mask> 'SEND_FILE_MAX_AGE_DEFAULT': timedelta(hours...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a1d9ebe4abebdb824aa9a397b001de5f9130e7a3
flask/app.py
def get_cookie_samesite(self, app): """Returns "Strict", "Lax" or None if the cookie should use samesite attribute. This currently just returns the value of the ``SESSION_COOKIE_SAMESITE`` setting. """ return app.config['SESSION_COOKIE_SAMESITE']
<mask> just returns the value of the ``SESSION_COOKIE_SECURE`` setting. <mask> """ <mask> return app.config['SESSION_COOKIE_SECURE'] <mask> <mask> def get_expiration_time(self, app, session): <mask> """A helper method that returns an expiration date for the session <mask> ...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a1d9ebe4abebdb824aa9a397b001de5f9130e7a3
flask/sessions.py
samesite = self.get_cookie_samesite(app)
<mask> <mask> httponly = self.get_cookie_httponly(app) <mask> secure = self.get_cookie_secure(app) <mask> expires = self.get_expiration_time(app, session) <mask> val = self.get_signing_serializer(app).dumps(dict(session)) <mask> response.set_cookie( <mask> app...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a1d9ebe4abebdb824aa9a397b001de5f9130e7a3
flask/sessions.py
secure=secure, samesite=samesite
<mask> expires=expires, <mask> httponly=httponly, <mask> domain=domain, <mask> path=path, <mask> secure=secure <mask> ) </s> New Feature: Added Support for cookie's SameSite attribute. </s> remove response.set_cookie('username', 'flask', secu...
[ "keep", "keep", "keep", "keep", "replace", "keep" ]
https://github.com/pallets/flask/commit/a1d9ebe4abebdb824aa9a397b001de5f9130e7a3
flask/sessions.py
SESSION_COOKIE_SAMESITE='Strict',
<mask> APPLICATION_ROOT='/test', <mask> SESSION_COOKIE_DOMAIN='.example.com', <mask> SESSION_COOKIE_HTTPONLY=False, <mask> SESSION_COOKIE_SECURE=True, <mask> SESSION_COOKIE_PATH='/' <mask> ) <mask> <mask> @app.route('/') <mask> def index(): <mask> f...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a1d9ebe4abebdb824aa9a397b001de5f9130e7a3
tests/test_basic.py
assert 'samesite' in cookie
<mask> assert 'secure' in cookie <mask> assert 'httponly' not in cookie <mask> <mask> <mask> def test_session_using_samesite_attribute(app, client): <mask> app.config.update( </s> New Feature: Added Support for cookie's SameSite attribute. </s> remove domain that created them. It is not supported...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a1d9ebe4abebdb824aa9a397b001de5f9130e7a3
tests/test_basic.py
greenlet==1.1.2 ; python_version < "3.11"
<mask> filelock==3.3.2 <mask> # via <mask> # tox <mask> # virtualenv <mask> greenlet==1.1.2 <mask> # via -r requirements/tests.in <mask> identify==2.3.3 <mask> # via pre-commit <mask> idna==3.3 <mask> # via requests </s> exclude greenlet tests on python 3.11 </s> remove greenlet ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a2258dd05d60b0d4fb4fef1d63dfe0ce489fd240
requirements/dev.txt
greenlet ; python_version < "3.11"
<mask> pytest <mask> asgiref <mask> blinker <mask> greenlet <mask> python-dotenv </s> exclude greenlet tests on python 3.11 </s> remove greenlet==1.1.2 </s> add greenlet==1.1.2 ; python_version < "3.11" </s> remove greenlet==1.1.2 </s> add greenlet==1.1.2 ; python_version < "3.11"
[ "keep", "keep", "keep", "replace", "keep" ]
https://github.com/pallets/flask/commit/a2258dd05d60b0d4fb4fef1d63dfe0ce489fd240
requirements/tests.in
greenlet==1.1.2 ; python_version < "3.11"
<mask> attrs==21.2.0 <mask> # via pytest <mask> blinker==1.4 <mask> # via -r requirements/tests.in <mask> greenlet==1.1.2 <mask> # via -r requirements/tests.in <mask> iniconfig==1.1.1 <mask> # via pytest <mask> packaging==21.2 <mask> # via pytest </s> exclude greenlet tests on python 3.11...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a2258dd05d60b0d4fb4fef1d63dfe0ce489fd240
requirements/tests.txt
@app.route('/', subdomain='foo') def sub(): return None
<mask> def index(): <mask> return None <mask> <mask> with app.test_request_context('/'): <mask> assert flask.url_for('index', _external=True) == 'http://localhost.localdomain:5000/' <mask> <mask> with app.test_request_context('/'): <mask> assert flas...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a327452540bbcffe73207f8164504115b6c9e856
tests/flask_tests.py
with app.test_request_context('/'): assert flask.url_for('sub', _external=True) == 'http://foo.localhost.localdomain:5000/' try:
<mask> <mask> with app.test_request_context('/'): <mask> assert flask.url_for('index', _external=True) == 'http://localhost.localdomain:5000/' <mask> <mask> def testit(): <mask> with app.test_request_context('/', environ_overrides={'HTTP_HOST': 'localhost'}): <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a327452540bbcffe73207f8164504115b6c9e856
tests/flask_tests.py
except Exception, e: assert isinstance(e, ValueError) assert str(e) == "the server name provided " + \ "('localhost.localdomain:5000') does not match the " + \ "server name from the WSGI environment ('localhost')", str(e) try: ...
<mask> <mask> def testit(): <mask> with app.test_request_context('/', environ_overrides={'HTTP_HOST': 'localhost'}): <mask> pass <mask> self.assertRaises(ValueError, testit) <mask> <mask> <mask> class JSONTestCase(unittest.TestCase): <mask> <mask> def test_j...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a327452540bbcffe73207f8164504115b6c9e856
tests/flask_tests.py
from jinja2 import Environment, BaseLoader, FileSystemLoader, TemplateNotFound
<mask> from threading import Lock <mask> from datetime import timedelta, datetime <mask> from itertools import chain <mask> <mask> from jinja2 import Environment, PackageLoader, FileSystemLoader <mask> from werkzeug import ImmutableDict, create_environ <mask> from werkzeug.routing import Map, Rule <mask> from ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a38dcd5e2bed1bcf2c1fc319fa9c3bc35e360fe0
flask/app.py
class _DispatchingJinjaLoader(BaseLoader): """A loader that looks for templates in the application and all the module folders.
<mask> # a lock used for logger initialization <mask> _logger_lock = Lock() <mask> <mask> <mask> def _select_autoescape(filename): <mask> """Returns `True` if autoescaping should be active for the given <mask> template name. <mask> """ <mask> if filename is None: <mask> return False ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a38dcd5e2bed1bcf2c1fc319fa9c3bc35e360fe0
flask/app.py
def __init__(self, app): self.app = app def get_source(self, environment, template): name = template loader = None try: module, name = template.split('/', 1) loader = self.app.modules[module].jinja_loader except (ValueError, KeyError): ...
<mask> def _select_autoescape(filename): <mask> """Returns `True` if autoescaping should be active for the given <mask> template name. <mask> """ <mask> if filename is None: <mask> return False <mask> return filename.endswith(('.html', '.htm', '.xml', '.xhtml')) <mask> <mask> <ma...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a38dcd5e2bed1bcf2c1fc319fa9c3bc35e360fe0
flask/app.py
<mask> ) <mask> <mask> #: Options that are passed directly to the Jinja2 environment. <mask> jinja_options = ImmutableDict( <mask> autoescape=_select_autoescape, <mask> extensions=['jinja2.ext.autoescape', 'jinja2.ext.with_'] <mask> ) <mask> <mask> #: Default configuration...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a38dcd5e2bed1bcf2c1fc319fa9c3bc35e360fe0
flask/app.py
#: all the loaded modules in a dictionary by name. #: #: .. versionadded:: 0.5 self.modules = {}
<mask> self.template_context_processors = { <mask> None: [_default_template_ctx_processor] <mask> } <mask> <mask> #: The :class:`~werkzeug.routing.Map` for this instance. You can use <mask> #: this to change the routing converters after the class was created <mask> ...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a38dcd5e2bed1bcf2c1fc319fa9c3bc35e360fe0
flask/app.py
#: :attr:`jinja_options`.
<mask> endpoint='static', <mask> view_func=self.send_static_file) <mask> <mask> #: The Jinja2 environment. It is created from the <mask> #: :attr:`jinja_options` and the loader that is returned <mask> #: by the :meth:`create_jin...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a38dcd5e2bed1bcf2c1fc319fa9c3bc35e360fe0
flask/app.py
options = dict(self.jinja_options) if 'autoescape' not in options: options['autoescape'] = self.select_jinja_autoescape return Environment(loader=_DispatchingJinjaLoader(self), **options)
<mask> and :meth:`create_jinja_loader`. <mask> <mask> .. versionadded:: 0.5 <mask> """ <mask> return Environment(loader=self.create_jinja_loader(), <mask> **self.jinja_options) <mask> <mask> def create_jinja_loader(self): <mask> """Create...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a38dcd5e2bed1bcf2c1fc319fa9c3bc35e360fe0
flask/app.py
def select_jinja_autoescape(self, filename): """Returns `True` if autoescaping should be active for the given template name. .. versionadded:: 0.5 """ if filename is None: return False return filename.endswith(('.html', '.htm', '.xml', '.xhtml'))
<mask> get_flashed_messages=get_flashed_messages <mask> ) <mask> self.jinja_env.filters['tojson'] = _tojson_filter <mask> <mask> def update_template_context(self, context): <mask> """Update the template context with some commonly used variables. <mask> This inject...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a38dcd5e2bed1bcf2c1fc319fa9c3bc35e360fe0
flask/app.py
from werkzeug import Headers, wrap_file, is_resource_modified, cached_property from jinja2 import FileSystemLoader
<mask> import json <mask> except ImportError: <mask> json_available = False <mask> <mask> from werkzeug import Headers, wrap_file, is_resource_modified <mask> <mask> from flask.globals import session, _request_ctx_stack, current_app, request <mask> from flask.wrappers import Response <mas...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a38dcd5e2bed1bcf2c1fc319fa9c3bc35e360fe0
flask/helpers.py
@cached_property def jinja_loader(self): """The Jinja loader for this package bound object. .. versionadded:: 0.5 """ template_folder = os.path.join(self.root_path, 'templates') if os.path.isdir(template_folder): return FileSystemLoader(template_folder)
<mask> return os.path.isdir(os.path.join(self.root_path, 'static')) <mask> <mask> def send_static_file(self, filename): <mask> """Function used internally to send static files from the static <mask> folder to the browser. <mask> <mask> .. versionadded:: 0.5 <mask> "...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a38dcd5e2bed1bcf2c1fc319fa9c3bc35e360fe0
flask/helpers.py
def _register_module(module):
<mask> <mask> from flask.helpers import _PackageBoundObject <mask> <mask> <mask> def _register_module_static(module): <mask> """Internal helper function that returns a function for recording <mask> that registers the `send_static_file` function for the module on <mask> the application of necessar...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a38dcd5e2bed1bcf2c1fc319fa9c3bc35e360fe0
flask/module.py
the application of necessary. It also registers the module on the application.
<mask> <mask> def _register_module_static(module): <mask> """Internal helper function that returns a function for recording <mask> that registers the `send_static_file` function for the module on <mask> the application of necessary. <mask> """ <mask> def _register_static(state): <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a38dcd5e2bed1bcf2c1fc319fa9c3bc35e360fe0
flask/module.py
def _register(state): state.app.modules[module.name] = module
<mask> """Internal helper function that returns a function for recording <mask> that registers the `send_static_file` function for the module on <mask> the application of necessary. <mask> """ <mask> def _register_static(state): <mask> # do not register the rule if the static folder of...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a38dcd5e2bed1bcf2c1fc319fa9c3bc35e360fe0
flask/module.py
return _register
<mask> path = state.url_prefix + path <mask> state.app.add_url_rule(path + '/<filename>', <mask> '%s.static' % module.name, <mask> view_func=module.send_static_file) <mask> return _register_static <mask> <mask> <mask> class ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a38dcd5e2bed1bcf2c1fc319fa9c3bc35e360fe0
flask/module.py
self._register_events = [_register_module(self)]
<mask> name = import_name.rsplit('.', 1)[1] <mask> _PackageBoundObject.__init__(self, import_name) <mask> self.name = name <mask> self.url_prefix = url_prefix <mask> self._register_events = [] <mask> <mask> # if there is a static folder, register it for this m...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a38dcd5e2bed1bcf2c1fc319fa9c3bc35e360fe0
flask/module.py
- Fixed an issue causing exceptions raised before entering a request or app context to be passed to teardown handlers.
<mask> - Fixed broken `test_appcontext_signals()` test case. <mask> - Raise an :exc:`AttributeError` in :func:`flask.helpers.find_package` with a <mask> useful message explaining why it is raised when a PEP 302 import hook is used <mask> without an `is_package()` method. <mask> <mask> Version 0.10.1 <mask> ...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a3a2f521f14ba90689efc661afe7a0375409c83e
CHANGES
if hasattr(sys, 'exc_clear'): sys.exc_clear()
<mask> """Binds the app context to the current context.""" <mask> self._refcnt += 1 <mask> _app_ctx_stack.push(self) <mask> appcontext_pushed.send(self.app) <mask> <mask> def pop(self, exc=None): <mask> """Pops the app context.""" </s> Clear exceptions when pushing a...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a3a2f521f14ba90689efc661afe7a0375409c83e
flask/ctx.py
if hasattr(sys, 'exc_clear'): sys.exc_clear()
<mask> self._implicit_app_ctx_stack.append(app_ctx) <mask> else: <mask> self._implicit_app_ctx_stack.append(None) <mask> <mask> _request_ctx_stack.push(self) <mask> <mask> # Open the session at the moment that the request context is <mask> # available. T...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a3a2f521f14ba90689efc661afe7a0375409c83e
flask/ctx.py
def test_teardown_with_previous_exception(self): buffer = [] app = flask.Flask(__name__) @app.teardown_request def end_of_request(exception): buffer.append(exception) try: raise Exception('dummy') except Exception: pass wi...
<mask> self.assert_equal(buffer, []) <mask> ctx.pop() <mask> self.assert_equal(buffer, [None]) <mask> <mask> def test_proper_test_request_context(self): <mask> app = flask.Flask(__name__) <mask> app.config.update( <mask> SERVER_NAME='localhost.localdomain...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a3a2f521f14ba90689efc661afe7a0375409c83e
flask/testsuite/reqctx.py
To do this we can create a function and hook it into the ``flask`` command that initializes the database. Let me show you the code first. Just add this function below the `connect_db` function in `flaskr.py`:: @app.cli.command() def initdb(): """Initializes the database.""" db = get_db() ...
<mask> require that we provide the path to the database which can introduce <mask> errors. It's a good idea to add a function that initializes the database <mask> for you to the application. <mask> <mask> To do this we can create a function called `init_db` that initializes the <mask> database. Let me show yo...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "re...
https://github.com/pallets/flask/commit/a3a5075a942a321ccf67c7511822e62dc1d5858f
docs/tutorial/dbinit.rst
Now it is possible to create a database with the ``flask`` script::
<mask> On that cursor there is a method to execute a complete script. Finally we <mask> only have to commit the changes. SQLite 3 and other transactional <mask> databases will not commit unless you explicitly tell it to. <mask> <mask> Now it is possible to create a database by starting up a Python shell and <m...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a3a5075a942a321ccf67c7511822e62dc1d5858f
docs/tutorial/dbinit.rst
flask --app=flaskr initdb Initialized the database.
<mask> <mask> Now it is possible to create a database by starting up a Python shell and <mask> importing and calling that function:: <mask> <mask> >>> from flaskr import init_db <mask> >>> init_db() <mask> <mask> .. admonition:: Troubleshooting <mask> <mask> If you get an exception later that a table c...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a3a5075a942a321ccf67c7511822e62dc1d5858f
docs/tutorial/dbinit.rst
you did execute the `initdb` command and that your table names are
<mask> <mask> .. admonition:: Troubleshooting <mask> <mask> If you get an exception later that a table cannot be found check that <mask> you did call the `init_db` function and that your table names are <mask> correct (singular vs. plural for example). <mask> <mask> Continue with :ref:`tutorial-view...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a3a5075a942a321ccf67c7511822e62dc1d5858f
docs/tutorial/dbinit.rst
<mask> <mask> # Load default config and override config from an environment variable <mask> app.config.update(dict( <mask> DATABASE=os.path.join(app.root_path, 'flaskr.db'), <mask> DEBUG=True, <mask> SECRET_KEY='development key', <mask> USERNAME='admin', <mask> P...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a3a5075a942a321ccf67c7511822e62dc1d5858f
docs/tutorial/setup.rst
Choose that key wisely and as hard to guess and complex as possible.
<mask> module. Flask will the initialize the variable from that module. Note <mask> that in all cases only variable names that are uppercase are considered. <mask> <mask> The ``SECRET_KEY`` is needed to keep the client-side sessions secure. <mask> Choose that key wisely and as hard to guess and complex as possi...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a3a5075a942a321ccf67c7511822e62dc1d5858f
docs/tutorial/setup.rst
<mask> rv = sqlite3.connect(app.config['DATABASE']) <mask> rv.row_factory = sqlite3.Row <mask> return rv <mask> <mask> Finally we just add a line to the bottom of the file that fires up the <mask> server if we want to run that file as a standalone application:: <mask> <mask> if __n...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a3a5075a942a321ccf67c7511822e62dc1d5858f
docs/tutorial/setup.rst
flask --app=flaskr --debug run The ``--debug`` flag enables or disables the interactive debugger. *Never leave debug mode activated in a production system*, because it will allow users to execute code on the server!
<mask> <mask> With that out of the way you should be able to start up the application <mask> without problems. Do this with the following command:: <mask> <mask> python flaskr.py <mask> <mask> You will see a message telling you that server has started along with <mask> the address at which you can access...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a3a5075a942a321ccf67c7511822e62dc1d5858f
docs/tutorial/setup.rst
@app.cli.command() def initdb():
<mask> rv.row_factory = sqlite3.Row <mask> return rv <mask> <mask> <mask> def init_db(): <mask> """Creates the database tables.""" <mask> with app.app_context(): <mask> db = get_db() <mask> with app.open_resource('schema.sql', mode='r') as f: <mask> db.cursor().ex...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a3a5075a942a321ccf67c7511822e62dc1d5858f
examples/flaskr/flaskr.py
db = get_db() with app.open_resource('schema.sql', mode='r') as f: db.cursor().executescript(f.read()) db.commit() print('Initialized the database.')
<mask> <mask> <mask> def init_db(): <mask> """Creates the database tables.""" <mask> with app.app_context(): <mask> db = get_db() <mask> with app.open_resource('schema.sql', mode='r') as f: <mask> db.cursor().executescript(f.read()) <mask> db.commit() <mask> <ma...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a3a5075a942a321ccf67c7511822e62dc1d5858f
examples/flaskr/flaskr.py
[request.form['title'], request.form['text']])
<mask> if not session.get('logged_in'): <mask> abort(401) <mask> db = get_db() <mask> db.execute('insert into entries (title, text) values (?, ?)', <mask> [request.form['title'], request.form['text']]) <mask> db.commit() <mask> flash('New entry was successfully posted...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a3a5075a942a321ccf67c7511822e62dc1d5858f
examples/flaskr/flaskr.py
<mask> def logout(): <mask> session.pop('logged_in', None) <mask> flash('You were logged out') <mask> return redirect(url_for('show_entries')) <mask> <mask> <mask> if __name__ == '__main__': <mask> init_db() <mask> app.run() </s> Updated tutorial to the flask script </s> remove Finally w...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace" ]
https://github.com/pallets/flask/commit/a3a5075a942a321ccf67c7511822e62dc1d5858f
examples/flaskr/flaskr.py
Hooking in WSGI Middlewares --------------------------- If you want to add a WSGI middleware to your application you can wrap the internal WSGI application. For example if you want to one of the middlewares from the Werkzeug package to work around bugs in lighttpd, you can do it like this:: from werkzeug.contrib...
<mask> <mask> The attached :attr:`~flask.Flask.logger` is a standard logging <mask> :class:`~logging.Logger`, so head over to the official stdlib <mask> documentation for more information. </s> Added middlewares to quickstart. This fixes #88 </s> remove self.url_adapter = app.url_map.bind_to_environ(envi...
[ "keep", "keep", "keep", "add" ]
https://github.com/pallets/flask/commit/a3a72e2d8d8df53164689fd84a5db2c6cd04f28a
docs/quickstart.rst
def create_url_adapter(self, request): """Creates a URL adapter for the given request. The URL adapter is created at a point where the request context is not yet set up so the request is passed explicitly. .. versionadded:: 0.6 """ return self.url_map.bind_to_enviro...
<mask> if isinstance(rv, tuple): <mask> return self.response_class(*rv) <mask> return self.response_class.force_type(rv, request.environ) <mask> <mask> def preprocess_request(self): <mask> """Called before the actual request dispatching and will <mask> call every ...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a3a72e2d8d8df53164689fd84a5db2c6cd04f28a
flask/app.py
<mask> """ <mask> <mask> def __init__(self, app, environ): <mask> self.app = app <mask> self.url_adapter = app.url_map.bind_to_environ(environ, <mask> server_name=app.config['SERVER_NAME']) <mask> self.request = app.request_class(environ) <mask> self.session ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a3a72e2d8d8df53164689fd84a5db2c6cd04f28a
flask/ctx.py
self.url_adapter = app.create_url_adapter(self.request)
<mask> self.app = app <mask> self.request = app.request_class(environ) <mask> self.session = app.open_session(self.request) <mask> if self.session is None: <mask> self.session = _NullSession() <mask> self.g = _RequestGlobals() <mask> self.flashes = None...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a3a72e2d8d8df53164689fd84a5db2c6cd04f28a
flask/ctx.py
first in a separate file otherwise the ``flask`` command won't be able to find it. Here an example `exampleapp.py` file that creates such an application::
<mask> Using Applications <mask> ------------------ <mask> <mask> So to use such an application you then have to create the application <mask> first. Here an example `run.py` file that runs such an application:: <mask> <mask> from yourapplication import create_app <mask> app = create_app('/path/to/co...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a3ad5405a68f312f077e8d6271e694f6925c0864
docs/patterns/appfactories.rst
It can then be used with the ``flask`` command:: flask --app=exampleapp run
<mask> first. Here an example `run.py` file that runs such an application:: <mask> <mask> from yourapplication import create_app <mask> app = create_app('/path/to/config.cfg') <mask> app.run() <mask> <mask> Factory Improvements <mask> -------------------- <mask> <mask> The factory function fro...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a3ad5405a68f312f077e8d6271e694f6925c0864
docs/patterns/appfactories.rst
<mask> flash('You were successfully logged in') <mask> return redirect(url_for('index')) <mask> return render_template('login.html', error=error) <mask> <mask> if __name__ == "__main__": <mask> app.run() <mask> <mask> <mask> And here the ``layout.html`` te...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a3ad5405a68f312f077e8d6271e694f6925c0864
docs/patterns/flashing.rst
else: raise NoAppException('The file provided (%s) does exist but is not a ' 'valid Python file. This means that it cannot ' 'be used as application. Please change the ' 'extension to .py' % filename)
<mask> filename = filename[:-3] <mask> elif os.path.split(filename)[1] == '__init__.py': <mask> filename = os.path.dirname(filename) <mask> filename = os.path.realpath(filename) <mask> <mask> dirpath = filename <mask> while 1: <mask> dirpath, extra = os.path.split(dirpat...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a3ad5405a68f312f077e8d6271e694f6925c0864
flask/cli.py
if loader is None or import_name == '__main__': # import name is not found, or interactive/main module
<mask> <mask> Not to be confused with the package path returned by :func:`find_package`. <mask> """ <mask> loader = pkgutil.get_loader(import_name) <mask> if loader is None: <mask> return os.getcwd() <mask> filepath = os.path.abspath(loader.get_filename(import_name)) <mask> # fi...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/a3b30b7e3b026e821716be63d586e078eaa6ee7f
flask/helpers.py