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
click.echo(message) click.echo(' * Environment: {0}'.format(env))
<mask> if not eager_loading: <mask> message += ' (lazy loading)' <mask> print(message) <mask> <mask> print(' * Environment: {0}'.format(env)) <mask> <mask> if env == 'production': <mask> click.secho( <mask> ' WARNING: Do not use the development server...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/80a9e0edf6208b3c1c9bc28bfb1a5f04b1f59e1d
flask/cli.py
from .app import Flask, Request, Response from .config import Config from .helpers import url_for, jsonify, json_available, flash, \
<mask> # in the module but are exported as public interface. <mask> from werkzeug import abort, redirect <mask> from jinja2 import Markup, escape <mask> <mask> from flask.app import Flask, Request, Response <mask> from flask.config import Config <mask> from flask.helpers import url_for, jsonify, json_available,...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/80eb6cfffc3f3fe6e448aa0e26ba1566d4c42917
flask/__init__.py
from .globals import current_app, g, request, session, _request_ctx_stack from .module import Module from .templating import render_template, render_template_string
<mask> from flask.app import Flask, Request, Response <mask> from flask.config import Config <mask> from flask.helpers import url_for, jsonify, json_available, flash, \ <mask> send_file, get_flashed_messages, get_template_attribute <mask> from flask.globals import current_app, g, request, session, _request_ctx...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/80eb6cfffc3f3fe6e448aa0e26ba1566d4c42917
flask/__init__.py
from .helpers import json
<mask> from flask.templating import render_template, render_template_string <mask> <mask> # only import json if it's available <mask> if json_available: <mask> from flask.helpers import json </s> Switched to relative imports in the package </s> remove from flask.globals import current_app, g, request, sessio...
[ "keep", "keep", "keep", "keep", "replace" ]
https://github.com/pallets/flask/commit/80eb6cfffc3f3fe6e448aa0e26ba1566d4c42917
flask/__init__.py
from .helpers import _PackageBoundObject, url_for, get_flashed_messages, \
<mask> from werkzeug import ImmutableDict, create_environ <mask> from werkzeug.routing import Map, Rule <mask> from werkzeug.exceptions import HTTPException, InternalServerError, NotFound <mask> <mask> from flask.helpers import _PackageBoundObject, url_for, get_flashed_messages, \ <mask> _tojson_filter <mas...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/80eb6cfffc3f3fe6e448aa0e26ba1566d4c42917
flask/app.py
from .wrappers import Request, Response from .config import ConfigAttribute, Config from .ctx import _RequestContext from .globals import _request_ctx_stack, request from .session import Session, _NullSession from .module import _ModuleSetupState from .templating import _DispatchingJinjaLoader, \
<mask> from werkzeug.exceptions import HTTPException, InternalServerError, NotFound <mask> <mask> from flask.helpers import _PackageBoundObject, url_for, get_flashed_messages, \ <mask> _tojson_filter <mask> from flask.wrappers import Request, Response <mask> from flask.config import ConfigAttribute, Config ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/80eb6cfffc3f3fe6e448aa0e26ba1566d4c42917
flask/app.py
from .globals import _request_ctx_stack from .session import _NullSession
<mask> """ <mask> <mask> from werkzeug.exceptions import HTTPException <mask> <mask> from flask.globals import _request_ctx_stack <mask> from flask.session import _NullSession <mask> <mask> <mask> class _RequestGlobals(object): <mask> pass <mask> </s> Switched to relative imports in the package </s...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/80eb6cfffc3f3fe6e448aa0e26ba1566d4c42917
flask/ctx.py
from .globals import session, _request_ctx_stack, current_app, request from .wrappers import Response
<mask> from werkzeug import Headers, wrap_file, is_resource_modified, cached_property <mask> <mask> from jinja2 import FileSystemLoader <mask> <mask> from flask.globals import session, _request_ctx_stack, current_app, request <mask> from flask.wrappers import Response <mask> <mask> <mask> def _assert_have_...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/80eb6cfffc3f3fe6e448aa0e26ba1566d4c42917
flask/helpers.py
from .globals import _request_ctx_stack
<mask> :license: BSD, see LICENSE for more details. <mask> """ <mask> from jinja2 import BaseLoader, FileSystemLoader, TemplateNotFound <mask> <mask> from flask.globals import _request_ctx_stack <mask> <mask> <mask> def _default_template_ctx_processor(): <mask> """Default template context processor....
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/80eb6cfffc3f3fe6e448aa0e26ba1566d4c42917
flask/templating.py
from .helpers import json
<mask> <mask> from werkzeug import Request as RequestBase, Response as ResponseBase, \ <mask> cached_property <mask> <mask> from helpers import json <mask> <mask> <mask> class Request(RequestBase): <mask> """The request object used by default in flask. Remembers the <mask> matched endpoint an...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/80eb6cfffc3f3fe6e448aa0e26ba1566d4c42917
flask/wrappers.py
- The :func:`flask.get_flashed_messages` function now allows rendering flashed message categories in separate blocks, through a ``category_filter`` argument.
<mask> - The Flask and Blueprint classes now have a non-decorator method for adding <mask> custom template filters application wide, <mask> :meth:`flask.Flask.add_template_filter` and <mask> :meth:`flask.Blueprint.add_app_template_filter`. <mask> <mask> <mask> Version 0.8.1 <mask> ------------- <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81010bf7afb786d3a19ddc2469f9bfdcc9e0d194
CHANGES
.. versionchanged:: 0.3
<mask> """Flashes a message to the next request. In order to remove the <mask> flashed message from the session and to display it to the user, <mask> the template has to call :func:`get_flashed_messages`. <mask> <mask> .. versionchanged: 0.3 <mask> `category` parameter added. <mask> <m...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81010bf7afb786d3a19ddc2469f9bfdcc9e0d194
flask/helpers.py
Filter the flashed messages to one or more categories by providing those categories in `category_filter`. This allows rendering categories in separate html blocks. The `with_categories` and `category_filter` arguments are distinct: * `with_categories` controls whether categories are returned with...
<mask> the same messages. By default just the messages are returned, <mask> but when `with_categories` is set to `True`, the return value will <mask> be a list of tuples in the form ``(category, message)`` instead. <mask> <mask> Example usage: <mask> <mask> .. sourcecode:: html+jinja <mas...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81010bf7afb786d3a19ddc2469f9bfdcc9e0d194
flask/helpers.py
.. versionchanged:: 0.9
<mask> <mask> .. versionchanged:: 0.3 <mask> `with_categories` parameter added. <mask> <mask> .. versionchanged: 0.9 <mask> `category_filter` parameter added. <mask> <mask> :param with_categories: set to `True` to also receive categories. <mask> :param category_filter: whiteli...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81010bf7afb786d3a19ddc2469f9bfdcc9e0d194
flask/helpers.py
def __init__(self, app_import_path=None, debug=None, create_app=None):
<mask> necessary to interface with as it's used internally in the dispatching <mask> to click. <mask> """ <mask> <mask> def __init__(self, app_import_path=None, debug=None, load_callback=None): <mask> self.app_import_path = app_import_path <mask> self.debug = debug <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81576c236a4dde33aeed13c84abed0ad2e796c2f
flask/cli.py
self.create_app = create_app
<mask> <mask> def __init__(self, app_import_path=None, debug=None, load_callback=None): <mask> self.app_import_path = app_import_path <mask> self.debug = debug <mask> self.load_callback = load_callback <mask> self._loaded_app = None <mask> <mask> def get_app_import_path...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81576c236a4dde33aeed13c84abed0ad2e796c2f
flask/cli.py
<mask> self.debug = debug <mask> self.load_callback = load_callback <mask> self._loaded_app = None <mask> <mask> def get_app_import_path(self): <mask> """Return the actual application import path or fails if it is <mask> not yet set. <mask> """ <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81576c236a4dde33aeed13c84abed0ad2e796c2f
flask/cli.py
"""Loads the Flask app (if not yet loaded) and returns it."""
<mask> return self.app_import_path <mask> _no_such_app() <mask> <mask> def load_app(self): <mask> """Loads the app (if not yet loaded) and returns it.""" <mask> if self._loaded_app is not None: <mask> return self._loaded_app <mask> if self.load_callba...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81576c236a4dde33aeed13c84abed0ad2e796c2f
flask/cli.py
if self.create_app is not None: rv = self.create_app(self)
<mask> def load_app(self): <mask> """Loads the app (if not yet loaded) and returns it.""" <mask> if self._loaded_app is not None: <mask> return self._loaded_app <mask> if self.load_callback is not None: <mask> rv = self.load_callback() <mask> else: <ma...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81576c236a4dde33aeed13c84abed0ad2e796c2f
flask/cli.py
if self.app_import_path is None: _no_such_app() rv = locate_app(self.app_import_path, self.debug)
<mask> return self._loaded_app <mask> if self.load_callback is not None: <mask> rv = self.load_callback() <mask> else: <mask> rv = locate_app(self.get_app_import_path(), self.debug) <mask> self._loaded_app = rv <mask> return rv <mask> <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81576c236a4dde33aeed13c84abed0ad2e796c2f
flask/cli.py
"""Returns a WSGI app that loads the actual application at a later stage (on first request). This has the advantage over :meth:`load_app` that if used with a WSGI server, it will allow the server to intercept errors later during request handling instead of dying a horrible death...
<mask> self._loaded_app = rv <mask> return rv <mask> <mask> def make_wsgi_app(self, use_eager_loading=False): <mask> """Returns a WSGI app that loads the actual application at a <mask> later stage. <mask> """ <mask> if self.app_import_path is not None: <mask...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81576c236a4dde33aeed13c84abed0ad2e796c2f
flask/cli.py
if self.create_app is None:
<mask> if self.app_import_path is not None: <mask> def loader(): <mask> return locate_app(self.app_import_path, self.debug) <mask> else: <mask> if self.load_callback is None: <mask> _no_such_app() <mask> def loader(): <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81576c236a4dde33aeed13c84abed0ad2e796c2f
flask/cli.py
return self.create_app(self)
<mask> else: <mask> if self.load_callback is None: <mask> _no_such_app() <mask> def loader(): <mask> return self.load_callback() <mask> return DispatchingApp(loader, use_eager_loading=use_eager_loading) <mask> <mask> @contextmanager <...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81576c236a4dde33aeed13c84abed0ad2e796c2f
flask/cli.py
"""Creates an application context or not, depending on the given parameter but always works as context manager. This is just a shortcut for a common operation.
<mask> return DispatchingApp(loader, use_eager_loading=use_eager_loading) <mask> <mask> @contextmanager <mask> def conditional_context(self, with_context=True): <mask> """Creates an application context or not, depending on the <mask> given parameter but always works as context man...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81576c236a4dde33aeed13c84abed0ad2e796c2f
flask/cli.py
with self.load_app(self).app_context() as ctx:
<mask> """Creates an application context or not, depending on the <mask> given parameter but always works as context manager. <mask> """ <mask> if with_context: <mask> with self.load_app().app_context() as ctx: <mask> yield ctx <mask> else: <ma...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81576c236a4dde33aeed13c84abed0ad2e796c2f
flask/cli.py
#: A special decorator that informs a click callback to be passed the #: script info object as first argument. This is normally not useful #: unless you implement very special commands like the run command which #: does not want the application to be loaded yet. This can be combined #: with the :func:`without_appcont...
<mask> yield None <mask> <mask> <mask> pass_script_info = click.make_pass_decorator(ScriptInfo) <mask> <mask> <mask> def without_appcontext(f): <mask> """Marks a click callback so that it does not get a app context <mask> created. This only works for commands directly registered to </...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81576c236a4dde33aeed13c84abed0ad2e796c2f
flask/cli.py
class FlaskGroup(click.Group): """Special subclass of the a regular click group that supports loading more commands from the configured Flask app. Normally a developer does not have to interface with this class but there are some very advanced usecases for which it makes sense to create an instance...
<mask> f.__flask_without_appcontext__ = True <mask> return f <mask> <mask> <mask> class ContextGroupMixin(object): <mask> <mask> def get_command(self, ctx, name): <mask> info = ctx.find_object(ScriptInfo) <mask> # Find the command in the application first, if we can find it. <ma...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81576c236a4dde33aeed13c84abed0ad2e796c2f
flask/cli.py
info = ctx.ensure_object(ScriptInfo)
<mask> <mask> class ContextGroupMixin(object): <mask> <mask> def get_command(self, ctx, name): <mask> info = ctx.find_object(ScriptInfo) <mask> # Find the command in the application first, if we can find it. <mask> # If the app is not available, we just ignore this silently. <mask>...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81576c236a4dde33aeed13c84abed0ad2e796c2f
flask/cli.py
return click.Group.get_command(self, ctx, name)
<mask> if rv is not None: <mask> return rv <mask> except NoAppException: <mask> pass <mask> return super(ContextGroupMixin, self).get_command(ctx, name) <mask> <mask> def list_commands(self, ctx): <mask> # The commands available is the list of...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81576c236a4dde33aeed13c84abed0ad2e796c2f
flask/cli.py
rv = set(click.Group.list_commands(self, ctx)) info = ctx.ensure_object(ScriptInfo)
<mask> <mask> def list_commands(self, ctx): <mask> # The commands available is the list of both the application (if <mask> # available) plus the builtin commands. <mask> rv = set(super(ContextGroupMixin, self).list_commands(ctx)) <mask> info = ctx.find_object(ScriptInfo) <mas...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81576c236a4dde33aeed13c84abed0ad2e796c2f
flask/cli.py
return click.Group.invoke_subcommand( self, ctx, cmd, cmd_name, args)
<mask> with_context = cmd.callback is None or \ <mask> not getattr(cmd.callback, '__flask_without_appcontext__', False) <mask> <mask> with ctx.find_object(ScriptInfo).conditional_context(with_context): <mask> return super(ContextGroupMixin, self).invoke_subcommand( <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81576c236a4dde33aeed13c84abed0ad2e796c2f
flask/cli.py
def main(self, *args, **kwargs): obj = kwargs.get('obj') if obj is None: obj = ScriptInfo(create_app=self.create_app) kwargs['obj'] = obj kwargs.setdefault('auto_envvar_prefix', 'FLASK') return click.Group.main(self, *args, **kwargs)
<mask> return super(ContextGroupMixin, self).invoke_subcommand( <mask> ctx, cmd, cmd_name, args) <mask> <mask> <mask> class FlaskGroup(ContextGroupMixin, click.Group): <mask> """Special subclass of the a regular click group that supports <mask> loading more commands from the...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81576c236a4dde33aeed13c84abed0ad2e796c2f
flask/cli.py
<mask> ctx.ensure_object(ScriptInfo).app_import_path = value <mask> def set_debug(ctx, value): <mask> ctx.ensure_object(ScriptInfo).debug = value <mask> <mask> click.Group.__init__(self, help=help, params=[ <mask> click.Option(['-a', '--app'], <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81576c236a4dde33aeed13c84abed0ad2e796c2f
flask/cli.py
@click.command('run', short_help='Runs a development server.')
<mask> help='Enable or disable debug mode.', <mask> default=None, callback=set_debug) <mask> ]) <mask> <mask> <mask> cli = FlaskGroup(help='''\ <mask> This shell command acts as general utility script for Flask applications. <mask> <mask> It loads th...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81576c236a4dde33aeed13c84abed0ad2e796c2f
flask/cli.py
"""Runs a local development server for the Flask application. This local server is recommended for development purposes only but it can also be used for simple intranet deployments. By default it will not support any sort of concurrency at all to simplify debugging. This can be changed with the -...
<mask> @without_appcontext <mask> @pass_script_info <mask> def run_command(info, host, port, reload, debugger, eager_loading, <mask> with_threads): <mask> """Runs a local development server for the Flask application.""" <mask> from werkzeug.serving import run_simple <mask> if reload i...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81576c236a4dde33aeed13c84abed0ad2e796c2f
flask/cli.py
@click.command('shell', short_help='Runs a shell in the app context.')
<mask> run_simple(host, port, app, use_reloader=reload, <mask> use_debugger=debugger, threaded=with_threads) <mask> <mask> <mask> @cli.command('shell', short_help='Runs a shell in the app context.') <mask> def shell_command(): <mask> """Runs an interactive Python shell in the context of ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81576c236a4dde33aeed13c84abed0ad2e796c2f
flask/cli.py
cli = FlaskGroup(help='''\ This shell command acts as general utility script for Flask applications. It loads the application configured (either through the FLASK_APP environment variable or the --app parameter) and then provides commands either provided by the application or Flask itself. The most useful commands ar...
<mask> return click.Group() <mask> <mask> <mask> def main(as_module=False): <mask> this_module = __package__ + '.cli' <mask> args = sys.argv[1:] <mask> <mask> if as_module: <mask> if sys.version_info >= (2, 7): </s> Further refactored script system to allow more customization for sp...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81576c236a4dde33aeed13c84abed0ad2e796c2f
flask/cli.py
cli.main(args=args, prog_name=name)
<mask> sys.argv = ['-m', this_module] + sys.argv[1:] <mask> else: <mask> name = None <mask> <mask> cli.main(args=args, prog_name=name, obj=ScriptInfo(), <mask> auto_envvar_prefix='FLASK') <mask> <mask> <mask> if __name__ == '__main__': <mask> main(as_module=True) <...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81576c236a4dde33aeed13c84abed0ad2e796c2f
flask/cli.py
view_func: t.Optional[ft.ViewCallable] = None,
<mask> def add_url_rule( <mask> self, <mask> rule: str, <mask> endpoint: t.Optional[str] = None, <mask> view_func: t.Optional[t.Callable] = None, <mask> provide_automatic_options: t.Optional[bool] = None, <mask> **options: t.Any, <mask> ) -> None: <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
src/flask/app.py
rv, status = rv # type: ignore[assignment,misc]
<mask> elif len_rv == 2: <mask> if isinstance(rv[1], (Headers, dict, tuple, list)): <mask> rv, headers = rv <mask> else: <mask> rv, status = rv # type: ignore[misc] <mask> # other sized tuples are not allowed <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
src/flask/app.py
view_func: t.Optional[ft.ViewCallable] = None,
<mask> def add_url_rule( <mask> self, <mask> rule: str, <mask> endpoint: t.Optional[str] = None, <mask> view_func: t.Optional[t.Callable] = None, <mask> provide_automatic_options: t.Optional[bool] = None, <mask> **options: t.Any, <mask> ) -> None: <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
src/flask/blueprints.py
) -> t.Callable[[ft.RouteDecorator], ft.RouteDecorator]:
<mask> self, <mask> method: str, <mask> rule: str, <mask> options: dict, <mask> ) -> t.Callable[[F], F]: <mask> if "methods" in options: <mask> raise TypeError("Use the 'route' decorator to use the 'methods' argument.") <mask> <mask> return self....
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
src/flask/scaffold.py
def get( self, rule: str, **options: t.Any ) -> t.Callable[[ft.RouteDecorator], ft.RouteDecorator]:
<mask> raise TypeError("Use the 'route' decorator to use the 'methods' argument.") <mask> <mask> return self.route(rule, methods=[method], **options) <mask> <mask> def get(self, rule: str, **options: t.Any) -> t.Callable[[F], F]: <mask> """Shortcut for :meth:`route` with ``method...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
src/flask/scaffold.py
def post( self, rule: str, **options: t.Any ) -> t.Callable[[ft.RouteDecorator], ft.RouteDecorator]:
<mask> .. versionadded:: 2.0 <mask> """ <mask> return self._method_route("GET", rule, options) <mask> <mask> def post(self, rule: str, **options: t.Any) -> t.Callable[[F], F]: <mask> """Shortcut for :meth:`route` with ``methods=["POST"]``. <mask> <mask> .. versionad...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
src/flask/scaffold.py
def put( self, rule: str, **options: t.Any ) -> t.Callable[[ft.RouteDecorator], ft.RouteDecorator]:
<mask> .. versionadded:: 2.0 <mask> """ <mask> return self._method_route("POST", rule, options) <mask> <mask> def put(self, rule: str, **options: t.Any) -> t.Callable[[F], F]: <mask> """Shortcut for :meth:`route` with ``methods=["PUT"]``. <mask> <mask> .. versionadd...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
src/flask/scaffold.py
def delete( self, rule: str, **options: t.Any ) -> t.Callable[[ft.RouteDecorator], ft.RouteDecorator]:
<mask> .. versionadded:: 2.0 <mask> """ <mask> return self._method_route("PUT", rule, options) <mask> <mask> def delete(self, rule: str, **options: t.Any) -> t.Callable[[F], F]: <mask> """Shortcut for :meth:`route` with ``methods=["DELETE"]``. <mask> <mask> .. versi...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
src/flask/scaffold.py
def patch( self, rule: str, **options: t.Any ) -> t.Callable[[ft.RouteDecorator], ft.RouteDecorator]:
<mask> .. versionadded:: 2.0 <mask> """ <mask> return self._method_route("DELETE", rule, options) <mask> <mask> def patch(self, rule: str, **options: t.Any) -> t.Callable[[F], F]: <mask> """Shortcut for :meth:`route` with ``methods=["PATCH"]``. <mask> <mask> .. vers...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
src/flask/scaffold.py
def route( self, rule: str, **options: t.Any ) -> t.Callable[[ft.RouteDecorator], ft.RouteDecorator]:
<mask> .. versionadded:: 2.0 <mask> """ <mask> return self._method_route("PATCH", rule, options) <mask> <mask> def route(self, rule: str, **options: t.Any) -> t.Callable[[F], F]: <mask> """Decorate a view function to register it with the given URL <mask> rule and opti...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
src/flask/scaffold.py
def decorator(f: ft.RouteDecorator) -> ft.RouteDecorator:
<mask> :param options: Extra options passed to the <mask> :class:`~werkzeug.routing.Rule` object. <mask> """ <mask> <mask> def decorator(f: F) -> F: <mask> endpoint = options.pop("endpoint", None) <mask> self.add_url_rule(rule, endpoint, f, **options) ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
src/flask/scaffold.py
view_func: t.Optional[ft.ViewCallable] = None,
<mask> def add_url_rule( <mask> self, <mask> rule: str, <mask> endpoint: t.Optional[str] = None, <mask> view_func: t.Optional[t.Callable] = None, <mask> provide_automatic_options: t.Optional[bool] = None, <mask> **options: t.Any, <mask> ) -> None: <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
src/flask/scaffold.py
ResponseValue = t.Union["Response", str, bytes, t.Dict[str, t.Any]]
<mask> from werkzeug.datastructures import Headers # noqa: F401 <mask> from werkzeug.wrappers import Response # noqa: F401 <mask> <mask> # The possible types that are directly convertible or are a Response object. <mask> ResponseValue = t.Union[ <mask> "Response", <mask> str, <mask> bytes...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
src/flask/typing.py
# This should be a Union, but mypy doesn't pass unless it's a TypeVar.
<mask> ] <mask> StatusCode = int <mask> <mask> # the possible types for an individual HTTP header <mask> HeaderName = str <mask> HeaderValue = t.Union[str, t.List[str], t.Tuple[str, ...]] <mask> <mask> # the possible types for HTTP headers <mask> HeadersValue = t.Union[ <mask> "Headers", t.Dict[HeaderNa...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
src/flask/typing.py
"Headers", t.Mapping[str, HeaderValue], t.Sequence[t.Tuple[str, HeaderValue]],
<mask> HeaderValue = t.Union[str, t.List[str], t.Tuple[str, ...]] <mask> <mask> # the possible types for HTTP headers <mask> HeadersValue = t.Union[ <mask> "Headers", t.Dict[HeaderName, HeaderValue], t.List[t.Tuple[HeaderName, HeaderValue]] <mask> ] <mask> <mask> # The possible types returned by a route f...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
src/flask/typing.py
t.Tuple[ResponseValue, int], t.Tuple[ResponseValue, int, HeadersValue],
<mask> # The possible types returned by a route function. <mask> ResponseReturnValue = t.Union[ <mask> ResponseValue, <mask> t.Tuple[ResponseValue, HeadersValue], <mask> t.Tuple[ResponseValue, StatusCode], <mask> t.Tuple[ResponseValue, StatusCode, HeadersValue], <mask> "WSGIApplication", <ma...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
src/flask/typing.py
<mask> from http import HTTPStatus <mask> from typing import Tuple <mask> from typing import Union <mask> <mask> from flask import Flask <mask> from flask import jsonify <mask> from flask.templating import render_template <mask> from flask.views import View </s> view function is actually type checked </s> rem...
[ "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
tests/typing/typing_route.py
@app.route("/str") def hello_str() -> str:
<mask> <mask> app = Flask(__name__) <mask> <mask> <mask> @app.route("/") <mask> def hello_world() -> str: <mask> return "<p>Hello, World!</p>" <mask> <mask> <mask> @app.route("/json") <mask> def hello_world_json() -> Response: </s> view function is actually type checked </s> remove def hello_world_...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
tests/typing/typing_route.py
@app.route("/bytes") def hello_bytes() -> bytes: return b"<p>Hello, World!</p>"
<mask> return "<p>Hello, World!</p>" <mask> <mask> <mask> @app.route("/json") <mask> def hello_json() -> Response: <mask> return jsonify({"response": "Hello, World!"}) <mask> <mask> <mask> @app.route("/status") </s> view function is actually type checked </s> remove def hello_world_json() -> Respo...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
tests/typing/typing_route.py
def hello_json() -> Response:
<mask> return "<p>Hello, World!</p>" <mask> <mask> <mask> @app.route("/json") <mask> def hello_world_json() -> Response: <mask> return jsonify({"response": "Hello, World!"}) <mask> <mask> <mask> @app.route("/template") <mask> @app.route("/template/<name>") </s> view function is actually type chec...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
tests/typing/typing_route.py
@app.route("/status") @app.route("/status/<int:code>") def tuple_status(code: int = 200) -> tuple[str, int]: return "hello", code @app.route("/status-enum") def tuple_status_enum() -> tuple[str, int]: return "hello", HTTPStatus.OK
<mask> def hello_world_json() -> Response: <mask> return jsonify({"response": "Hello, World!"}) <mask> <mask> <mask> @app.route("/template") <mask> @app.route("/template/<name>") <mask> def return_template(name: Union[str, None] = None) -> str: <mask> return render_template("index.html", name=name) <...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
tests/typing/typing_route.py
@app.route("/headers") def tuple_headers() -> tuple[str, dict[str, str]]: return "Hello, World!", {"Content-Type": "text/plain"}
<mask> def return_template(name: Union[str, None] = None) -> str: <mask> return render_template("index.html", name=name) <mask> <mask> <mask> @app.errorhandler(HTTPStatus.INTERNAL_SERVER_ERROR) <mask> def error_500(e) -> Tuple[str, int]: <mask> return "<p>Sorry, we are having problems</p>", HTTPStatus....
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
tests/typing/typing_route.py
@app.route("/template") @app.route("/template/<name>") def return_template(name: str | None = None) -> str: return render_template("index.html", name=name)
<mask> def error_500(e) -> Tuple[str, int]: <mask> return "<p>Sorry, we are having problems</p>", HTTPStatus.INTERNAL_SERVER_ERROR <mask> <mask> <mask> @app.before_request <mask> def before_request() -> None: <mask> app.logger.debug("Executing a sample before_request function") <mask> return None ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
tests/typing/typing_route.py
def __init__(self: RenderTemplateView, template_name: str) -> None:
<mask> return None <mask> <mask> <mask> class RenderTemplateView(View): <mask> def __init__(self: "RenderTemplateView", template_name: str) -> None: <mask> self.template_name = template_name <mask> <mask> def dispatch_request(self: "RenderTemplateView") -> str: <mask> return rend...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
tests/typing/typing_route.py
def dispatch_request(self: RenderTemplateView) -> str:
<mask> class RenderTemplateView(View): <mask> def __init__(self: "RenderTemplateView", template_name: str) -> None: <mask> self.template_name = template_name <mask> <mask> def dispatch_request(self: "RenderTemplateView") -> str: <mask> return render_template(self.template_name) <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81be290ec8889c157c84bc7ce857f883396c5daf
tests/typing/typing_route.py
- From Werkzeug, for redirect responses the ``Location`` header URL will remain relative, and exclude the scheme and domain, by default. :pr:`4496`
<mask> - Fix typing for ``__exit__`` methods for better compatibility with <mask> ``ExitStack``. :issue:`4474` <mask> <mask> <mask> Version 2.0.3 <mask> ------------- <mask> </s> update tests for relative redirects </s> remove assert response.headers['Location'] == 'http://localhost/' </s> add...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81c7ff7f8db09b5d609a09722785f70ec6f7af68
CHANGES.rst
assert response.headers["Location"] == "/auth/login"
<mask> assert client.get('/auth/register').status_code == 200 <mask> response = client.post( <mask> '/auth/register', data={'username': 'a', 'password': 'a'} <mask> ) <mask> assert 'http://localhost/auth/login' == response.headers['Location'] <mask> <mask> wit...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81c7ff7f8db09b5d609a09722785f70ec6f7af68
docs/tutorial/tests.rst
assert response.headers["Location"] == "/"
<mask> <mask> def test_login(client, auth): <mask> assert client.get('/auth/login').status_code == 200 <mask> response = auth.login() <mask> assert response.headers['Location'] == 'http://localhost/' <mask> <mask> with client: <mask> client.get('/') <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81c7ff7f8db09b5d609a09722785f70ec6f7af68
docs/tutorial/tests.rst
assert response.headers["Location"] == "/auth/login"
<mask> '/1/delete', <mask> )) <mask> def test_login_required(client, path): <mask> response = client.post(path) <mask> assert response.headers['Location'] == 'http://localhost/auth/login' <mask> <mask> <mask> def test_author_required(app, client, auth): <mask> # ch...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81c7ff7f8db09b5d609a09722785f70ec6f7af68
docs/tutorial/tests.rst
assert response.headers["Location"] == "/"
<mask> <mask> def test_delete(client, auth, app): <mask> auth.login() <mask> response = client.post('/1/delete') <mask> assert response.headers['Location'] == 'http://localhost/' <mask> <mask> with app.app_context(): <mask> db = get_db() <mask> post...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81c7ff7f8db09b5d609a09722785f70ec6f7af68
docs/tutorial/tests.rst
assert response.headers["Location"] == "/auth/login"
<mask> assert client.get("/auth/register").status_code == 200 <mask> <mask> # test that successful registration redirects to the login page <mask> response = client.post("/auth/register", data={"username": "a", "password": "a"}) <mask> assert "http://localhost/auth/login" == response.headers["Loca...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81c7ff7f8db09b5d609a09722785f70ec6f7af68
examples/tutorial/tests/test_auth.py
assert response.headers["Location"] == "/"
<mask> assert client.get("/auth/login").status_code == 200 <mask> <mask> # test that successful login redirects to the index page <mask> response = auth.login() <mask> assert response.headers["Location"] == "http://localhost/" <mask> <mask> # login request set the user_id in the session <m...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81c7ff7f8db09b5d609a09722785f70ec6f7af68
examples/tutorial/tests/test_auth.py
assert response.headers["Location"] == "/auth/login"
<mask> <mask> @pytest.mark.parametrize("path", ("/create", "/1/update", "/1/delete")) <mask> def test_login_required(client, path): <mask> response = client.post(path) <mask> assert response.headers["Location"] == "http://localhost/auth/login" <mask> <mask> <mask> def test_author_required(app, client...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81c7ff7f8db09b5d609a09722785f70ec6f7af68
examples/tutorial/tests/test_blog.py
assert response.headers["Location"] == "/"
<mask> <mask> def test_delete(client, auth, app): <mask> auth.login() <mask> response = client.post("/1/delete") <mask> assert response.headers["Location"] == "http://localhost/" <mask> <mask> with app.app_context(): <mask> db = get_db() <mask> post = db.execute("SELECT * FROM...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81c7ff7f8db09b5d609a09722785f70ec6f7af68
examples/tutorial/tests/test_blog.py
autocorrect_location_header = False
<mask> json_module = json <mask> <mask> @property <mask> def max_cookie_size(self) -> int: # type: ignore <mask> """Read-only view of the :data:`MAX_COOKIE_SIZE` config key. <mask> <mask> See :attr:`~werkzeug.wrappers.Response.max_cookie_size` in </s> update tests for relative red...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81c7ff7f8db09b5d609a09722785f70ec6f7af68
src/flask/wrappers.py
location_parts = rv.headers["Location"].rpartition("/") if location_parts[0]: # For older Werkzeug that used absolute redirects. assert location_parts[0] == "http://localhost" assert location_parts[2] == "test"
<mask> raise Foo() <mask> <mask> with app.test_client() as c: <mask> rv = c.get("/") <mask> assert rv.headers["Location"] == "http://localhost/test" <mask> rv = c.get("/test") <mask> assert rv.data == b"42" </s> update tests for relative redirects </s> remove ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep" ]
https://github.com/pallets/flask/commit/81c7ff7f8db09b5d609a09722785f70ec6f7af68
tests/test_regression.py
And here is the :file:`layout.html` template which does the magic:
<mask> flash('You were successfully logged in') <mask> return redirect(url_for('index')) <mask> return render_template('login.html', error=error) <mask> <mask> And here the :file:`layout.html` template which does the magic: <mask> <mask> .. sourcecode:: html+jinja <mask...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81e8bbbb7f5f7e43f37da5b76071aa52b2c0e5c7
docs/patterns/flashing.rst
Here is the :file:`index.html` template which inherits from :file:`layout.html`:
<mask> {% endif %} <mask> {% endwith %} <mask> {% block body %}{% endblock %} <mask> <mask> And here the index.html template: <mask> <mask> .. sourcecode:: html+jinja <mask> <mask> {% extends "layout.html" %} <mask> {% block body %} </s> improve grammar, make format consistent, and improv...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81e8bbbb7f5f7e43f37da5b76071aa52b2c0e5c7
docs/patterns/flashing.rst
And here is the :file:`login.html` template which also inherits from :file:`layout.html`:
<mask> <h1>Overview</h1> <mask> <p>Do you want to <a href="{{ url_for('login') }}">log in?</a> <mask> {% endblock %} <mask> <mask> And of course the login template: <mask> <mask> .. sourcecode:: html+jinja <mask> <mask> {% extends "layout.html" %} <mask> {% block body %} </s> improve gr...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/81e8bbbb7f5f7e43f37da5b76071aa52b2c0e5c7
docs/patterns/flashing.rst
def test_add_template_filter(self): app = flask.Flask(__name__) def my_reverse(s): return s[::-1] app.add_template_filter(my_reverse) self.assert_('my_reverse' in app.jinja_env.filters.keys()) self.assert_equal(app.jinja_env.filters['my_reverse'], my_reverse) ...
<mask> self.assert_('my_reverse' in app.jinja_env.filters.keys()) <mask> self.assert_equal(app.jinja_env.filters['my_reverse'], my_reverse) <mask> self.assert_equal(app.jinja_env.filters['my_reverse']('abcd'), 'dcba') <mask> <mask> def test_template_filter_with_name(self): <mask> ...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/820d099e82aa8ee01e1e82b85e2c6636d63be98a
flask/testsuite/templating.py
def test_add_template_filter_with_name(self): app = flask.Flask(__name__) def my_reverse(s): return s[::-1] app.add_template_filter(my_reverse, 'strrev') self.assert_('strrev' in app.jinja_env.filters.keys()) self.assert_equal(app.jinja_env.filters['strrev'], my_...
<mask> self.assert_equal(app.jinja_env.filters['strrev']('abcd'), 'dcba') <mask> <mask> def test_template_filter_with_template(self): <mask> app = flask.Flask(__name__) <mask> @app.template_filter() <mask> def super_reverse(s): <mask> return s[::-1] </s> Add test...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/820d099e82aa8ee01e1e82b85e2c6636d63be98a
flask/testsuite/templating.py
def test_add_template_filter_with_template(self): app = flask.Flask(__name__) def super_reverse(s): return s[::-1] app.add_template_filter(super_reverse) @app.route('/') def index(): return flask.render_template('template_filter.html', value='abcd') ...
<mask> return flask.render_template('template_filter.html', value='abcd') <mask> rv = app.test_client().get('/') <mask> self.assert_equal(rv.data, 'dcba') <mask> <mask> def test_template_filter_with_name_and_template(self): <mask> app = flask.Flask(__name__) <mask> ...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/820d099e82aa8ee01e1e82b85e2c6636d63be98a
flask/testsuite/templating.py
def test_add_template_filter_with_name_and_template(self): app = flask.Flask(__name__) def my_reverse(s): return s[::-1] app.add_template_filter(my_reverse, 'super_reverse') @app.route('/') def index(): return flask.render_template('template_filter.htm...
<mask> return flask.render_template('template_filter.html', value='abcd') <mask> rv = app.test_client().get('/') <mask> self.assert_equal(rv.data, 'dcba') <mask> <mask> def test_custom_template_loader(self): <mask> class MyFlask(flask.Flask): <mask> def create...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/820d099e82aa8ee01e1e82b85e2c6636d63be98a
flask/testsuite/templating.py
set-cookie behavior. If set to ``True`` a permanent session will be
<mask> - Added `**kwargs` to :meth:`flask.Test.test_client` to support passing <mask> additional keyword arguments to the constructor of <mask> :attr:`flask.Flask.test_client_class`. <mask> - Added ``SESSION_REFRESH_EACH_REQUEST`` config key that controls the <mask> set-cookie behavior. If set to `True` a p...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8284217593d5ea3d4bdeaed1e146fa94578b7999
CHANGES
``False`` it will only be modified if the session actually modifies.
<mask> :attr:`flask.Flask.test_client_class`. <mask> - Added ``SESSION_REFRESH_EACH_REQUEST`` config key that controls the <mask> set-cookie behavior. If set to `True` a permanent session will be <mask> refreshed each request and get their lifetime extended, if set to <mask> `False` it will only be modifi...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8284217593d5ea3d4bdeaed1e146fa94578b7999
CHANGES
environ ``werkzeug.request`` will be ``None`` after the response was
<mask> - Logger now only returns the debug log setting if it was not set <mask> explicitly. <mask> - Unregister a circular dependency between the WSGI environment and <mask> the request object when shutting down the request. This means that <mask> environ ``werkzeug.request`` will be `None` after the respon...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8284217593d5ea3d4bdeaed1e146fa94578b7999
CHANGES
- The :meth:`flask.Flask.run` method now accepts ``None`` for `host` and `port` arguments, using default values when ``None``. This allows for calling run
<mask> :meth:`flask.Blueprint.add_app_template_filter`. <mask> - The :func:`flask.get_flashed_messages` function now allows rendering flashed <mask> message categories in separate blocks, through a ``category_filter`` <mask> argument. <mask> - The :meth:`flask.Flask.run` method now accepts `None` for `host` ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8284217593d5ea3d4bdeaed1e146fa94578b7999
CHANGES
``True`` if the request was triggered via a JavaScript
<mask> ============= ====================================================== <mask> <mask> .. attribute:: is_xhr <mask> <mask> `True` if the request was triggered via a JavaScript <mask> `XMLHttpRequest`. This only works with libraries that support the <mask> ``X-Requested-With`` head...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8284217593d5ea3d4bdeaed1e146fa94578b7999
docs/api.rst
``True`` if the session is new, ``False`` otherwise.
<mask> The following attributes are interesting: <mask> <mask> .. attribute:: new <mask> <mask> `True` if the session is new, `False` otherwise. <mask> <mask> .. attribute:: modified <mask> <mask> `True` if the session object detected a modification. Be advised <mask> that modi...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8284217593d5ea3d4bdeaed1e146fa94578b7999
docs/api.rst
``True`` if the session object detected a modification. Be advised
<mask> `True` if the session is new, `False` otherwise. <mask> <mask> .. attribute:: modified <mask> <mask> `True` if the session object detected a modification. Be advised <mask> that modifications on mutable structures are not picked up <mask> automatically, in that situation you ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8284217593d5ea3d4bdeaed1e146fa94578b7999
docs/api.rst
attribute to ``True`` yourself. Here an example::
<mask> <mask> `True` if the session object detected a modification. Be advised <mask> that modifications on mutable structures are not picked up <mask> automatically, in that situation you have to explicitly set the <mask> attribute to `True` yourself. Here an example:: <mask> <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8284217593d5ea3d4bdeaed1e146fa94578b7999
docs/api.rst
If set to ``True`` the session lives for
<mask> session.modified = True <mask> <mask> .. attribute:: permanent <mask> <mask> If set to `True` the session lives for <mask> :attr:`~flask.Flask.permanent_session_lifetime` seconds. The <mask> default is 31 days. If set to `False` (which is the default) the <mask> s...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8284217593d5ea3d4bdeaed1e146fa94578b7999
docs/api.rst
default is 31 days. If set to ``False`` (which is the default) the
<mask> .. attribute:: permanent <mask> <mask> If set to `True` the session lives for <mask> :attr:`~flask.Flask.permanent_session_lifetime` seconds. The <mask> default is 31 days. If set to `False` (which is the default) the <mask> session will be deleted when the user closes the bro...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8284217593d5ea3d4bdeaed1e146fa94578b7999
docs/api.rst
get an attribute or ``None`` (or the second argument) if it's not set.
<mask> is especially useful when combined with the :ref:`faking-resources` <mask> pattern for testing. <mask> <mask> Additionally as of 0.10 you can use the :meth:`get` method to <mask> get an attribute or `None` (or the second argument) if it's not set. <mask> These two usages are now equivalent:...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8284217593d5ea3d4bdeaed1e146fa94578b7999
docs/api.rst
``True`` if the signaling system is available. This is the case
<mask> .. versionadded:: 0.6 <mask> <mask> .. data:: signals_available <mask> <mask> `True` if the signaling system is available. This is the case <mask> when `blinker`_ is installed. <mask> <mask> .. data:: template_rendered <mask> <mask> This signal is sent when a template was successfully ren...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8284217593d5ea3d4bdeaed1e146fa94578b7999
docs/api.rst
explicitly set to ``None`` this is
<mask> ``DEBUG`` enable/disable debug mode <mask> ``TESTING`` enable/disable testing mode <mask> ``PROPAGATE_EXCEPTIONS`` explicitly enable or disable the <mask> propagation of exceptions. If not set or <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8284217593d5ea3d4bdeaed1e146fa94578b7999
docs/config.rst
``True``.
<mask> for all of ``APPLICATION_ROOT`` or if <mask> that is not set for ``'/'``. <mask> ``SESSION_COOKIE_HTTPONLY`` controls if the cookie should be set <mask> with the httponly flag. Defaults to <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8284217593d5ea3d4bdeaed1e146fa94578b7999
docs/config.rst
``False``.
<mask> with the httponly flag. Defaults to <mask> `True`. <mask> ``SESSION_COOKIE_SECURE`` controls if the cookie should be set <mask> with the secure flag. Defaults to <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8284217593d5ea3d4bdeaed1e146fa94578b7999
docs/config.rst
sessions are refreshed. If set to ``True``
<mask> :class:`datetime.timedelta` object. <mask> Starting with Flask 0.8 this can also be <mask> an integer representing seconds. <mask> ``SESSION_REFRESH_EACH_REQUEST`` this flag controls how permanent <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8284217593d5ea3d4bdeaed1e146fa94578b7999
docs/config.rst
set to ``False`` a `set-cookie` header is
<mask> sessions are refreshed. If set to `True` <mask> (which is the default) then the cookie <mask> is refreshed each request which <mask> automatically bumps the lifetime. If ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8284217593d5ea3d4bdeaed1e146fa94578b7999
docs/config.rst
falls back to another application if the creator function returns ``None``::
<mask> app = self.default_app <mask> return app(environ, start_response) <mask> <mask> The big difference between this and the subdomain one is that this one <mask> falls back to another application if the creator function returns `None`:: <mask> <mask> from myapplication import...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8284217593d5ea3d4bdeaed1e146fa94578b7999
docs/patterns/appdispatch.rst
will return ``None``::
<mask> <mask> To get an item from the cache call <mask> :meth:`~werkzeug.contrib.cache.BaseCache.get` with a string as key name. <mask> If something is in the cache, it is returned. Otherwise that function <mask> will return `None`:: <mask> <mask> rv = cache.get('my-item') <mask> <mask> To add items to...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/8284217593d5ea3d4bdeaed1e146fa94578b7999
docs/patterns/caching.rst