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
from werkzeug.urls import url_quote
<mask> from werkzeug.routing import RoutingException <mask> from werkzeug.routing import Rule <mask> from werkzeug.utils import redirect as _wz_redirect <mask> from werkzeug.wrappers import Response as BaseResponse <mask> <mask> from . import cli <mask> from . import json </s> add url_for method to app </s> re...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/92acd05d9bd33419ab885e4472b28a1d5cc15d2e
src/flask/app.py
<mask> from threading import RLock <mask> <mask> import werkzeug.utils <mask> from werkzeug.exceptions import abort as _wz_abort <mask> from werkzeug.routing import BuildError <mask> from werkzeug.urls import url_quote <mask> from werkzeug.utils import redirect as _wz_redirect <mask> <mask> from .globals imp...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/92acd05d9bd33419ab885e4472b28a1d5cc15d2e
src/flask/helpers.py
return current_app.url_for(endpoint, external, url_adapter, **values)
<mask> ) <mask> <mask> external = values.pop("_external", True) <mask> <mask> anchor = values.pop("_anchor", None) <mask> method = values.pop("_method", None) <mask> scheme = values.pop("_scheme", None) <mask> appctx.app.inject_url_defaults(endpoint, values) <mask> <mask...
[ "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/92acd05d9bd33419ab885e4472b28a1d5cc15d2e
src/flask/helpers.py
<mask> This is a basic view function that generates a lot of CSV data on the fly. <mask> The trick is to have an inner function that uses a generator to generate <mask> data and to then invoke that function and pass it to a response object:: <mask> <mask> from flask import Response <mask> <mask> @app.r...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/92f648b04eda0c8563a43c60d989ce416137e920
docs/patterns/streaming.rst
return app.response_class(generate(), mimetype='text/csv')
<mask> def generate_large_csv(): <mask> def generate(): <mask> for row in iter_all_rows(): <mask> yield f"{','.join(row)}\n" <mask> return Response(generate(), mimetype='text/csv') <mask> <mask> Each ``yield`` expression is directly sent to the browser. Note thou...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/92f648b04eda0c8563a43c60d989ce416137e920
docs/patterns/streaming.rst
<mask> The Jinja2 template engine also supports rendering templates piece by <mask> piece. This functionality is not directly exposed by Flask because it is <mask> quite uncommon, but you can easily do it yourself:: <mask> <mask> from flask import Response <mask> <mask> def stream_template(template_na...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/92f648b04eda0c8563a43c60d989ce416137e920
docs/patterns/streaming.rst
return app.response_class(stream_template('the_template.html', rows=rows))
<mask> <mask> @app.route('/my-large-page.html') <mask> def render_large_template(): <mask> rows = iter_all_rows() <mask> return Response(stream_template('the_template.html', rows=rows)) <mask> <mask> The trick here is to get the template object from the Jinja2 environment <mask> on the...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/92f648b04eda0c8563a43c60d989ce416137e920
docs/patterns/streaming.rst
from flask import stream_with_context, request
<mask> moment the function executes. Flask 0.9 provides you with a helper that <mask> can keep the request context around during the execution of the <mask> generator:: <mask> <mask> from flask import stream_with_context, request, Response <mask> <mask> @app.route('/stream') <mask> def streamed_r...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/92f648b04eda0c8563a43c60d989ce416137e920
docs/patterns/streaming.rst
return app.response_class(stream_with_context(generate()))
<mask> def generate(): <mask> yield 'Hello ' <mask> yield request.args['name'] <mask> yield '!' <mask> return Response(stream_with_context(generate())) <mask> <mask> Without the :func:`~flask.stream_with_context` function you would get a <mask> :class:`Runtim...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/92f648b04eda0c8563a43c60d989ce416137e920
docs/patterns/streaming.rst
only the application context is bound and not yet a request. This is especially useful when combined with the :ref:`faking-resources` pattern for testing. Additionally as of 0.10 you can use the subscription operator syntax to get an attribute or `None` if it's not set. These two usages are now equ...
<mask> connection or the user that is currently logged in. <mask> <mask> Starting with Flask 0.10 this is stored on the application context and <mask> no longer on the request context which means it becomes available if <mask> only the application context is bound and not yet a request. <mask> <mas...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/93073489a0321225090bb21548521c2047219937
docs/api.rst
.. _faking-resources:
<mask> This in general is less useful because at that point you can directly <mask> start using the test client. <mask> <mask> <mask> Faking Resources and Context <mask> ---------------------------- <mask> </s> Documented changes on the g object some more </s> remove only the application context is bound ...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/93073489a0321225090bb21548521c2047219937
docs/testing.rst
def test_subscript_syntax_on_g(self): app = flask.Flask(__name__) app.testing = True with app.app_context(): self.assert_equal(flask.g['x'], None) flask.g.x = 42 self.assert_equal(flask.g['x'], 42) self.assert_equal(flask.g.x, 42) ...
<mask> c.get('/success') <mask> self.assert_equal(len(errors), 3) <mask> self.assert_equal(errors[1], None) <mask> <mask> <mask> class SubdomainTestCase(FlaskTestCase): <mask> <mask> def test_basic_support(self): </s> Documented changes on the g object some more </s> remove on...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/93073489a0321225090bb21548521c2047219937
flask/testsuite/basic.py
.. _virtualenv:
<mask> method is virtualenv, so let's look at that first. <mask> <mask> virtualenv <mask> ---------- <mask> <mask> Virtualenv is what you want to use during development and in production if <mask> you have shell access. So first: what does virtualenv do? If you are <mask> like me and you like Python, chance...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/931dcc4c80331d372d70d7a0a5c8e6d49223e2bf
docs/installation.rst
Simple Flashing ---------------
<mask> possible to record a message at the end of a request and access it next <mask> request and only next request. This is usually combined with a layout <mask> template that does this. <mask> <mask> So here a full example:: <mask> <mask> from flask import flash, redirect, url_for, render_template <mas...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/931dcc4c80331d372d70d7a0a5c8e6d49223e2bf
docs/patterns/flashing.rst
distribute
<mask> :maxdepth: 2 <mask> <mask> packages <mask> sqlite3 <mask> sqlalchemy <mask> fileuploads <mask> caching <mask> viewdecorators </s> Fixed a doc bug and added distribtue docs. </s> remove kind of string and be used as category. </s> add kind ...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/931dcc4c80331d372d70d7a0a5c8e6d49223e2bf
docs/patterns/index.rst
kind of string can be used as category.
<mask> :param category: the category for the message. The following values <mask> are recommended: ``'message'`` for any kind of message, <mask> ``'error'`` for errors, ``'info'`` for information <mask> messages and ``'warning'`` for warnings. How...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/931dcc4c80331d372d70d7a0a5c8e6d49223e2bf
flask.py
.. autoclass:: AppGroup :members:
<mask> .. autoclass:: FlaskGroup <mask> :members: <mask> <mask> .. autoclass:: ScriptInfo <mask> :members: <mask> <mask> .. autofunction:: with_appcontext </s> Refactored the scripting interface greatly. </s> remove does not want the application to be loaded yet. This can be combined with the :fu...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/932f7d7cbb5a4e04fd0922c3272a6e32d408abe8
docs/api.rst
.. autofunction:: with_appcontext
<mask> .. autoclass:: ScriptInfo <mask> :members: <mask> <mask> .. autofunction:: pass_script_info <mask> <mask> .. autofunction:: without_appcontext <mask> </s> Refactored the scripting interface greatly. </s> remove does not want the application to be loaded yet. This can be combined with the :fu...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/932f7d7cbb5a4e04fd0922c3272a6e32d408abe8
docs/api.rst
does not want the application to be loaded yet.
<mask> <mask> A special decorator that informs a click callback to be passed the <mask> script info object as first argument. This is normally not useful <mask> unless you implement very special commands like the run command which <mask> does not want the application to be loaded yet. This can be co...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/932f7d7cbb5a4e04fd0922c3272a6e32d408abe8
docs/api.rst
from . import json, cli
<mask> MethodNotAllowed, BadRequest <mask> <mask> from .helpers import _PackageBoundObject, url_for, get_flashed_messages, \ <mask> locked_cached_property, _endpoint_from_view_func, find_package <mask> from . import json <mask> from .wrappers import Request, Response <mask> from .config import ConfigA...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/932f7d7cbb5a4e04fd0922c3272a6e32d408abe8
flask/app.py
self.cli = cli.AppGroup(self)
<mask> #: application has been discovered. The default commands are <mask> #: provided by Flask itself and can be overridden. <mask> #: <mask> #: This is an instance of a :class:`click.Group` object. <mask> self.cli = click.Group(self) <mask> <mask> def _get_error_ha...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/932f7d7cbb5a4e04fd0922c3272a6e32d408abe8
flask/app.py
from functools import update_wrapper
<mask> <mask> import os <mask> import sys <mask> from threading import Lock <mask> from contextlib import contextmanager <mask> <mask> import click <mask> <mask> from ._compat import iteritems <mask> </s> Refactored the scripting interface greatly. </s> remove from . import json </s> add from . import j...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/932f7d7cbb5a4e04fd0922c3272a6e32d408abe8
flask/cli.py
<mask> rv.debug = self.debug <mask> self._loaded_app = rv <mask> return rv <mask> <mask> @contextmanager <mask> def conditional_context(self, with_context=True): <mask> """Creates an application context or not, depending on the given <mask> parameter but alwa...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/932f7d7cbb5a4e04fd0922c3272a6e32d408abe8
flask/cli.py
pass_script_info = click.make_pass_decorator(ScriptInfo, ensure=True)
<mask> else: <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 dire...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/932f7d7cbb5a4e04fd0922c3272a6e32d408abe8
flask/cli.py
def with_appcontext(f): """Wraps a callback so that it's guaranteed to be executed with the script's application context. If callbacks are registered directly to the ``app.cli`` object then they are wrapped with this function by default unless it's disabled.
<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 <mask> the toplevel system. This real...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/932f7d7cbb5a4e04fd0922c3272a6e32d408abe8
flask/cli.py
@click.pass_context def decorator(__ctx, *args, **kwargs): with __ctx.ensure_object(ScriptInfo).load_app().app_context(): return __ctx.invoke(f, *args, **kwargs) return update_wrapper(decorator, f)
<mask> created. This only works for commands directly registered to <mask> the toplevel system. This really is only useful for very <mask> special commands like the runserver one. <mask> """ <mask> f.__flask_without_appcontext__ = True <mask> return f <mask> <mask> <mask> def set_de...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/932f7d7cbb5a4e04fd0922c3272a6e32d408abe8
flask/cli.py
this. Not to be confused with :class:`AppGroup`.
<mask> """Special subclass of the a regular click group that supports loading <mask> more commands from the configured Flask app. Normally a developer <mask> does not have to interface with this class but there are some very <mask> advanced usecases for which it makes sense to create an instance of...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/932f7d7cbb5a4e04fd0922c3272a6e32d408abe8
flask/cli.py
<mask> # the app again and this will give us the error. <mask> pass <mask> return sorted(rv) <mask> <mask> def invoke_subcommand(self, ctx, cmd, cmd_name, args): <mask> with_context = cmd.callback is None or \ <mask> not getattr(cmd.callback, '__flask_witho...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/932f7d7cbb5a4e04fd0922c3272a6e32d408abe8
flask/cli.py
<mask> help='Enable or disable eager loading. By default eager ' <mask> 'loading is enabled if the reloader is disabled.') <mask> @click.option('--with-threads/--without-threads', default=False, <mask> help='Enable or disable multithreading.') <mask> @without_appcontext ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/932f7d7cbb5a4e04fd0922c3272a6e32d408abe8
flask/cli.py
@with_appcontext
<mask> use_debugger=debugger, threaded=with_threads) <mask> <mask> <mask> @click.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 a given <mask> Flask application. The application wil...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/932f7d7cbb5a4e04fd0922c3272a6e32d408abe8
flask/cli.py
accommodate large-scale applications:
<mask> In that case, it makes a lot of sense to use dotted names for the URL <mask> endpoints. <mask> <mask> Here are some suggestions for how Flask can be modified to better <mask> accomodate large-scale applications: <mask> <mask> - implement dotted names for URL endpoints <mask> - get rid of the decor...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/93a8ca02822d07cd9f13495f53d27ab22e9adf3a
docs/becomingbig.rst
specifying the target functions explicitly or by name and importing
<mask> of troubles for applications that have circular dependencies. It <mask> also requires that the whole application is imported when the system <mask> initializes or certain URLs will not be available right away. A <mask> better solution would be to have one module with all URLs in there and ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/93a8ca02822d07cd9f13495f53d27ab22e9adf3a
docs/becomingbig.rst
explicit instantiation of that class: the package name. Whenever you
<mask> possible without hacks if the object were created ahead of time for you <mask> based on a class that is not exposed to you. <mask> <mask> But there is another very important reason why Flask depends on an <mask> explicit instanciation of that class: the package name. Whenever you <mask> create a Flask in...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/93a8ca02822d07cd9f13495f53d27ab22e9adf3a
docs/design.rst
infrastructure, packages with dependencies are no longer an issue and
<mask> <mask> Flask is a framework that takes advantage of the work already done by <mask> Werkzeug to properly interface WSGI (which can be a complex task at <mask> times). Thanks to recent developments in the Python package <mask> infrastructure, packages with depencencies are no longer an issue and <mask> th...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/93a8ca02822d07cd9f13495f53d27ab22e9adf3a
docs/design.rst
for large applications or asynchronous servers. Flask wants to make it
<mask> <mask> Yes it is usually not such a bright idea to use thread locals. They cause <mask> troubles for servers that are not based on the concept of threads and make <mask> large applications harder to maintain. However Flask is just not designed <mask> for large applications or asyncronous servers. Flask ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/93a8ca02822d07cd9f13495f53d27ab22e9adf3a
docs/design.rst
on the kind of attack, chances are there are automated botnets out there trying to figure out how to fill your database with viagra advertisements.
<mask> up in situations where we think "well, this is just far fetched, how could <mask> that possibly be exploited" and then an intelligent guy comes along and <mask> figures a way out to exploit that application. And don't think, your <mask> application is not important enough for hackers to take notice. Depend...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/93a8ca02822d07cd9f13495f53d27ab22e9adf3a
docs/foreword.rst
Is Flask for you? If your application small-ish (less than 4000 lines of
<mask> <mask> Target Audience <mask> --------------- <mask> <mask> Is Flask for you? Is your application small-ish (less than 4000 lines of <mask> Python code) and does not depend on too complex database structures, Flask <mask> is the Framework for you. It was designed from the ground up to be easy <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/93a8ca02822d07cd9f13495f53d27ab22e9adf3a
docs/foreword.rst
This will pull in the dependencies and activate the git head as current
<mask> $ python setup.py develop <mask> ... <mask> Finished processing dependencies for Flask <mask> <mask> This will pull in the depdenencies and activate the git head as current <mask> version. Then you just have to ``git pull origin`` to get the latest <mask> version. <mask> <mask> To just ge...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/93a8ca02822d07cd9f13495f53d27ab22e9adf3a
docs/installation.rst
application object::
<mask> you enable the debug support the server will reload itself on code changes <mask> and also provide you with a helpful debugger if things go wrong. <mask> <mask> There are two ways to enable debugging. Either set that flag on the <mask> applciation object:: <mask> <mask> app.debug = True <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/93a8ca02822d07cd9f13495f53d27ab22e9adf3a
docs/quickstart.rst
your function. Optionally a converter can be specified by specifying a
<mask> likely he will like the page and come back next time. <mask> <mask> To add variable parts to a URL you can mark these special sections as <mask> ``<variable_name>``. Such a part is then passed as keyword argument to <mask> your function. Optionally a converter can be specifed by specifying a <mask> rule...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/93a8ca02822d07cd9f13495f53d27ab22e9adf3a
docs/quickstart.rst
<mask> ... <mask> >>> with app.test_request_context(): <mask> ... print url_for('index') <mask> ... print url_for('login') <mask> ... print url_for('profile', username='John Doe') <mask> ... print url_for('login', next='/') <mask> ... <mask> / <mask> /login <mask> /login?next=/ </s> Fixed some minor ty...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/93a8ca02822d07cd9f13495f53d27ab22e9adf3a
docs/quickstart.rst
... print url_for('profile', username='John Doe')
<mask> ... print url_for('login') <mask> ... print url_for('login', next='/') <mask> ... <mask> / <mask> /login <mask> /login?next=/ </s> Fixed some minor typos throughout docs. </s> remove ... print url_for('profile', username='John Doe') </s> add </s> remove This will pull in the depdenencies and activat...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/93a8ca02822d07cd9f13495f53d27ab22e9adf3a
docs/quickstart.rst
package it's actually inside your package:
<mask> return render_template('hello.html', name=name) <mask> <mask> Flask will look for templates in the `templates` folder. So if your <mask> application is a module, that folder is next to that module, if it's a <mask> pacakge it's actually inside your package: <mask> <mask> **Case 1**: a module:: ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/93a8ca02822d07cd9f13495f53d27ab22e9adf3a
docs/quickstart.rst
For a full list of methods and attributes on that object, head over to the
<mask> We recommend accessing URL parameters with `get` or by catching the <mask> `KeyError` because users might change the URL and presenting them a 400 <mask> bad request page in that case is a bit user unfriendly. <mask> <mask> For a full list of methods and attribtues on that object, head over to the <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/93a8ca02822d07cd9f13495f53d27ab22e9adf3a
docs/quickstart.rst
attribute on your HTML form, otherwise the browser will not transmit your
<mask> ```````````` <mask> <mask> Obviously you can handle uploaded files with Flask just as easy. Just <mask> make sure not to forget to set the ``enctype="multipart/form-data"`` <mask> attribtue on your HTML form, otherwise the browser will not transmit your <mask> files at all. <mask> <mask> Uploaded file...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/93a8ca02822d07cd9f13495f53d27ab22e9adf3a
docs/quickstart.rst
not found. By default 200 is assumed which translates to: all went well.
<mask> return render_template('page_not_found.html'), 404 <mask> <mask> Note the ``404`` after the :func:`~flask.render_template` call. This <mask> tells Flask that the status code of that page should be 404 which means <mask> not found. By default 200 is assumed which translats to: all went well. <mas...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/93a8ca02822d07cd9f13495f53d27ab22e9adf3a
docs/quickstart.rst
for you and signs the cookies cryptographically. What this means is that
<mask> <mask> Besides the request object there is also a second object called <mask> :class:`~flask.session` that allows you to store information specific to a <mask> user from one request to the next. This is implemented on top of cookies <mask> for you and signes the cookies cryptographically. What this means...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/93a8ca02822d07cd9f13495f53d27ab22e9adf3a
docs/quickstart.rst
``url_for``. Registering the same blueprint with the same name multiple times is deprecated. :issue:`1091`
<mask> locations. :issue:`4069` <mask> - ``register_blueprint`` takes a ``name`` option to change the <mask> (pre-dotted) name the blueprint is registered with. This allows the <mask> same blueprint to be registered multiple times with unique names for <mask> ``url_for``. :issue:`1091` <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9409be6e34e153bfdb0aac2c9eb7f60110109172
CHANGES.rst
<mask> The ``name`` option can be used to change the (pre-dotted) <mask> name the blueprint is registered with. This allows the same <mask> blueprint to be registered multiple times with unique names <mask> for ``url_for``. <mask> """ <mask> first_re...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9409be6e34e153bfdb0aac2c9eb7f60110109172
src/flask/blueprints.py
.. versionchanged:: 2.0.1 Registering the same blueprint with the same name multiple times is deprecated and will become an error in Flask 2.1. """ first_registration = not any(bp is self for bp in app.blueprints.values())
<mask> for ``url_for``. <mask> <mask> name_prefix = options.get("name_prefix", "") <mask> self_name = options.get("name", self.name) <mask> name = f"{name_prefix}.{self_name}".lstrip(".") <mask> </s> warn when registering same blueprint with same name </s> remove """...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9409be6e34e153bfdb0aac2c9eb7f60110109172
src/flask/blueprints.py
if name in app.blueprints: existing_at = f" '{name}'" if self_name != name else "" if app.blueprints[name] is not self: raise ValueError( f"The name '{self_name}' is already registered for" f" a different blueprint{existing_at}. Us...
<mask> name_prefix = options.get("name_prefix", "") <mask> self_name = options.get("name", self.name) <mask> name = f"{name_prefix}.{self_name}".lstrip(".") <mask> <mask> if name in app.blueprints and app.blueprints[name] is not self: <mask> raise ValueError( <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9409be6e34e153bfdb0aac2c9eb7f60110109172
src/flask/blueprints.py
app.register_blueprint(bp, name="test2", url_prefix="/2", url_defaults={"bar": 19})
<mask> def bar(bar): <mask> return str(bar) <mask> <mask> app.register_blueprint(bp, url_prefix="/1", url_defaults={"bar": 23}) <mask> app.register_blueprint(bp, url_prefix="/2", url_defaults={"bar": 19}) <mask> <mask> assert client.get("/1/foo").data == b"23/42" <mask> assert clie...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9409be6e34e153bfdb0aac2c9eb7f60110109172
tests/test_blueprints.py
with pytest.warns(UserWarning): app.register_blueprint(bp) # same bp, same name, warning app.register_blueprint(bp, name="again") # same bp, different name, ok
<mask> bp = flask.Blueprint("bp", __name__) <mask> bp2 = flask.Blueprint("bp", __name__) <mask> <mask> app.register_blueprint(bp) <mask> app.register_blueprint(bp) # same name, same object, no error <mask> <mask> with pytest.raises(ValueError): <mask> app.register_blueprint(bp2) ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9409be6e34e153bfdb0aac2c9eb7f60110109172
tests/test_blueprints.py
app.register_blueprint(bp2) # different bp, same name, error
<mask> app.register_blueprint(bp) <mask> app.register_blueprint(bp) # same name, same object, no error <mask> <mask> with pytest.raises(ValueError): <mask> app.register_blueprint(bp2) # same name, different object <mask> <mask> app.register_blueprint(bp2, name="alt") # different name...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep" ]
https://github.com/pallets/flask/commit/9409be6e34e153bfdb0aac2c9eb7f60110109172
tests/test_blueprints.py
app.register_blueprint(bp2, name="alt") # different bp, different name, ok
<mask> <mask> with pytest.raises(ValueError): <mask> app.register_blueprint(bp2) # same name, different object <mask> <mask> app.register_blueprint(bp2, name="alt") # different name </s> warn when registering same blueprint with same name </s> remove app.register_blueprint(bp2) # same...
[ "keep", "keep", "keep", "keep", "replace" ]
https://github.com/pallets/flask/commit/9409be6e34e153bfdb0aac2c9eb7f60110109172
tests/test_blueprints.py
- Raise an :exc:`AttributeError` in :func:`flask.helpers.find_package` with a useful message explaining why it is raised when a PEP 302 import hook is used without an `is_package()` method.
<mask> <mask> - Fixed broken `test_appcontext_signals()` test case. <mask> <mask> Version 0.10.1 <mask> -------------- <mask> <mask> (bugfix release, released on June 14th 2013) <mask> </s> Explain is_package AttributeError in find_package When a PEP 302 import hook is used that doesn't implement .is_pack...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/94f436013792249a9bb7206c2868d4c6c21fd887
CHANGES
if hasattr(loader, 'is_package'): if loader.is_package(root_mod_name): package_path = os.path.dirname(package_path) else: raise AttributeError( ('%s.is_package() method is missing but is ' 'required by Flask of PEP 302 import hooks...
<mask> __import__(import_name) <mask> filename = sys.modules[import_name].__file__ <mask> package_path = os.path.abspath(os.path.dirname(filename)) <mask> # package_path ends with __init__.py for a package <mask> if loader.is_package(root_mod_name): <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/94f436013792249a9bb7206c2868d4c6c21fd887
flask/helpers.py
from flask._compat import PY2
<mask> from contextlib import contextmanager <mask> from flask.testsuite import FlaskTestCase <mask> <mask> <mask> # config keys used for the ConfigTestCase <mask> TEST_KEY = 'foo' <mask> SECRET_KEY = 'devkey' <mask> </s> Explain is_package AttributeError in find_package When a PEP 302 import hook is used ...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/94f436013792249a9bb7206c2868d4c6c21fd887
flask/testsuite/config.py
if PY2: def test_meta_path_loader_without_is_package(self): class Loader(object): def find_module(self, name): return self sys.meta_path.append(Loader()) try: with self.assert_raises(AttributeError): ...
<mask> del sys.modules['site_egg'] <mask> <mask> <mask> def suite(): <mask> suite = unittest.TestSuite() <mask> suite.addTest(unittest.makeSuite(ConfigTestCase)) </s> Explain is_package AttributeError in find_package When a PEP 302 import hook is used that doesn't implement .is_package...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/94f436013792249a9bb7206c2868d4c6c21fd887
flask/testsuite/config.py
if __name__ == '__main__': WSGIServer(app).run()
<mask> from flup.server.fcgi import WSGIServer <mask> from yourapplication import app <mask> <mask> This is enough for Apache to work, however nginx and older versions of <mask> lighttpd need a socket to be explicitly passed to communicate with the FastCGI <mask> server. For that to work you need to pas...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/94f90bc4eb88224d6639cbe94c4e88d8299644e2
docs/deploying/fastcgi.rst
This is enough for Apache to work, however nginx and older versions of lighttpd need a socket to be explicitly passed to communicate with the FastCGI server. For that to work you need to pass the path to the socket to the
<mask> #!/usr/bin/python <mask> from flup.server.fcgi import WSGIServer <mask> from yourapplication import app <mask> <mask> WSGIServer(app).run() <mask> <mask> This is enough for Apache to work, however lighttpd and nginx need a <mask> socket to communicate with the FastCGI server. For that ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/94f90bc4eb88224d6639cbe94c4e88d8299644e2
docs/deploying/fastcgi.rst
fastcgi.server = ("/yourapplication.fcgi" => ((
<mask> -------------------- <mask> <mask> A basic FastCGI configuration for lighttpd looks like that:: <mask> <mask> fastcgi.server = ("/yourapplication" => <mask> "yourapplication" => ( <mask> "socket" => "/tmp/yourapplication-fcgi.sock", <mask> "bin-path" => "/var/www/you...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/94f90bc4eb88224d6639cbe94c4e88d8299644e2
docs/deploying/fastcgi.rst
"check-local" => "disable", "max-procs" -> 1 )) ) alias.url = ( "/static/" => "/path/to/your/static"
<mask> fastcgi.server = ("/yourapplication" => <mask> "yourapplication" => ( <mask> "socket" => "/tmp/yourapplication-fcgi.sock", <mask> "bin-path" => "/var/www/yourapplication/yourapplication.fcgi", <mask> "check-local" => "disable" <mask> ) <mask> ) ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/94f90bc4eb88224d6639cbe94c4e88d8299644e2
docs/deploying/fastcgi.rst
url.rewrite-once = ( "^(/static.*)$" => "$1", "^(/.*)$" => "/yourapplication.fcgi$1" Remember to enable the FastCGI, alias and rewrite modules. This configuration binds the application to `/yourapplication`. If you want the application to work in the URL root you have to work around a lighttpd bug...
<mask> "check-local" => "disable" <mask> ) <mask> ) <mask> <mask> This configuration binds the application to `/yourapplication`. If you <mask> want the application to work in the URL root you have to work around a <mask> lighttpd bug with the :class:`~werkzeug.contrib.fixers.LighttpdCG...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/94f90bc4eb88224d6639cbe94c4e88d8299644e2
docs/deploying/fastcgi.rst
root. Also, see the Lighty docs for more information on `FastCGI and Python <http://redmine.lighttpd.net/wiki/lighttpd/Docs:ModFastCGI>`_ (note that explicitly passing a socket to run() is no longer necessary).
<mask> lighttpd bug with the :class:`~werkzeug.contrib.fixers.LighttpdCGIRootFix` <mask> middleware. <mask> <mask> Make sure to apply it only if you are mounting the application the URL <mask> root. <mask> <mask> Configuring nginx <mask> ----------------- <mask> <mask> Installing FastCGI applications on ng...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/94f90bc4eb88224d6639cbe94c4e88d8299644e2
docs/deploying/fastcgi.rst
To run such an application, you can use the :command:`flask` command::
<mask> <mask> Using Applications <mask> ------------------ <mask> <mask> To use such an application you have to create it in a separate file first, <mask> otherwise the :command:`flask` command won't be able to find it. Here's an <mask> example :file:`exampleapp.py` file that creates such an application:: <ma...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/94fd3edf3185ea20f1b3af62c247e031cd8136dd
docs/patterns/appfactories.rst
export FLASK_APP=myapp flask run Flask will automatically detect the factory (``create_app`` or ``make_app``) in ``myapp``. You can also pass arguments to the factory like this::
<mask> To use such an application you have to create it in a separate file first, <mask> otherwise the :command:`flask` command won't be able to find it. Here's an <mask> example :file:`exampleapp.py` file that creates such an application:: <mask> <mask> from yourapplication import create_app <mask> app ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/94fd3edf3185ea20f1b3af62c247e031cd8136dd
docs/patterns/appfactories.rst
export FLASK_APP="myapp:create_app('dev')"
<mask> app = create_app('/path/to/config.cfg') <mask> <mask> It can then be used with the :command:`flask` command:: <mask> <mask> export FLASK_APP=exampleapp <mask> flask run <mask> <mask> Factory Improvements <mask> -------------------- <mask> </s> Docs: Update CLI for factory pattern </s> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/94fd3edf3185ea20f1b3af62c247e031cd8136dd
docs/patterns/appfactories.rst
Then the ``create_app`` factory in ``myapp`` is called with the string ``'dev'`` as the argument. See :doc:`/cli` for more detail.
<mask> in ``myapp``. You can also pass arguments to the factory like this:: <mask> <mask> export FLASK_APP="myapp:create_app('dev')" <mask> flask run <mask> <mask> Factory Improvements <mask> -------------------- <mask> <mask> The factory function above is not very clever, but you can improve it. <...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/94fd3edf3185ea20f1b3af62c247e031cd8136dd
docs/patterns/appfactories.rst
- Added :meth:`~flask.Flask.make_default_options_response` which can be used by subclasses to alter the default behaviour for `OPTIONS` responses.
<mask> <mask> Release date to be announced, codename to be selected <mask> <mask> Version 0.6.1 <mask> ------------- <mask> <mask> Bugfix release, release date to be announced. </s> In 0.7, make_default_options_response is a public API </s> remove def _make_default_options_response(self): </s> add d...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/952967fcab0ffccc6b67485e8eed994a69d38d03
CHANGES
return self.make_default_options_response()
<mask> rule = req.url_rule <mask> # if we provide automatic options for this URL and the <mask> # request came with the OPTIONS method, reply automatically <mask> if rule.provide_automatic_options and req.method == 'OPTIONS': <mask> return self._make...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/952967fcab0ffccc6b67485e8eed994a69d38d03
flask/app.py
def make_default_options_response(self): """This method is called to create the default `OPTIONS` response. This can be changed through subclassing to change the default behaviour of `OPTIONS` responses. .. versionadded:: 0.7 """
<mask> return self.view_functions[rule.endpoint](**req.view_args) <mask> except HTTPException, e: <mask> return self.handle_http_exception(e) <mask> <mask> def _make_default_options_response(self): <mask> # This would be nicer in Werkzeug 0.7, which however currently ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/952967fcab0ffccc6b67485e8eed994a69d38d03
flask/app.py
`url_root` ``http://www.example.com/myapplication/``
<mask> `path` ``/page.html`` <mask> `script_root` ``/myapplication`` <mask> `url` ``http://www.example.com/myapplication/page.html`` <mask> `base_url` ``http://www.example.com/myapplication/page.html?x=y`` <mask> `root_url` ``http://www.example.com/myapplication/`...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/95750b3287bfa21fbb706f10a3a9fbcef01c089e
docs/api.rst
ImmutableDict, cached_property
<mask> <mask> from jinja2 import Environment, PackageLoader, FileSystemLoader <mask> from werkzeug import Request as RequestBase, Response as ResponseBase, \ <mask> LocalStack, LocalProxy, create_environ, SharedDataMiddleware, \ <mask> cached_property <mask> from werkzeug.routing import Map, Rule <mas...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/95750b3287bfa21fbb706f10a3a9fbcef01c089e
flask.py
jinja_options = ImmutableDict(
<mask> #: The secure cookie uses this for the name of the session cookie <mask> session_cookie_name = 'session' <mask> <mask> #: options that are passed directly to the Jinja2 environment <mask> jinja_options = dict( <mask> autoescape=True, <mask> extensions=['jinja2.ext.autoesca...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/95750b3287bfa21fbb706f10a3a9fbcef01c089e
flask.py
#: the :class:`~werkzeug.routing.Map` for this instance. You can use #: this to change the routing converters after the class was created #: but before any routes are connected. Example:: #: #: from werkzeug import BaseConverter #: #: class ListConverter(B...
<mask> #: To register a function here, use the :meth:`context_processor` <mask> #: decorator. <mask> self.template_context_processors = [_default_template_ctx_processor] <mask> <mask> self.url_map = Map() <mask> <mask> if self.static_path is not None: <mask> ...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/95750b3287bfa21fbb706f10a3a9fbcef01c089e
flask.py
self.add_url_rule(self.static_path + '/<filename>', build_only=True, endpoint='static')
<mask> <mask> self.url_map = Map() <mask> <mask> if self.static_path is not None: <mask> self.url_map.add(Rule(self.static_path + '/<filename>', <mask> build_only=True, endpoint='static')) <mask> if pkg_resources is not None: <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/95750b3287bfa21fbb706f10a3a9fbcef01c089e
flask.py
def test_custom_converters(self): from werkzeug.routing import BaseConverter class ListConverter(BaseConverter): def to_python(self, value): return value.split(',') def to_url(self, value): return ','.join(super(ListConverter, self).to_url(x) f...
<mask> assert flask.url_for('hello', name='test x') == '/hello/test%20x' <mask> <mask> def test_static_files(self): <mask> app = flask.Flask(__name__) <mask> rv = app.test_client().get('/static/index.html') <mask> assert rv.status_code == 200 <mask> assert rv.data...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/95750b3287bfa21fbb706f10a3a9fbcef01c089e
tests/flask_tests.py
Version 1.1.0 -------------
<mask> Flask Changelog <mask> =============== <mask> <mask> <mask> Version 1.1 <mask> ----------- <mask> <mask> Unreleased <mask> <mask> - :meth:`flask.RequestContext.copy` includes the current session <mask> object in the request context copy. This prevents ``session`` </s> use dict literal synta...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/957f48a98dd7d598c55a521967a2fddcd12a4efd
CHANGES.rst
- :attr:`Flask.jinja_options` is a ``dict`` instead of an ``ImmutableDict`` to allow easier configuration. Changes must still be made before creating the environment. :pr:`3190`
<mask> - :func:`open_resource` accepts the "rt" file mode. This still does <mask> the same thing as "r". :issue:`3163` <mask> - The :attr:`MethodView.methods` attribute set in a base class is used <mask> by subclasses. :issue:`3138` <mask> <mask> .. _#2935: https://github.com/pallets/flask/issues/293...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/957f48a98dd7d598c55a521967a2fddcd12a4efd
CHANGES.rst
#: Options that are passed to the Jinja environment in #: :meth:`create_jinja_environment`. Changing these options after #: the environment is created (accessing :attr:`jinja_env`) will #: have no effect. #: #: .. versionchanged:: 1.1.0 #: This is a ``dict`` instead of an ``ImmutableDict...
<mask> #: <mask> #: .. versionadded:: 0.10 <mask> json_decoder = json.JSONDecoder <mask> <mask> #: Options that are passed directly to the Jinja2 environment. <mask> jinja_options = dict( <mask> extensions=["jinja2.ext.autoescape", "jinja2.ext.with_"] <mask> ) <mask> <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/957f48a98dd7d598c55a521967a2fddcd12a4efd
flask/app.py
"""The Jinja environment used to load templates. The environment is created the first time this property is accessed. Changing :attr:`jinja_options` after that will have no effect. """
<mask> return create_logger(self) <mask> <mask> @locked_cached_property <mask> def jinja_env(self): <mask> """The Jinja2 environment used to load templates.""" <mask> return self.create_jinja_environment() <mask> <mask> @property <mask> def got_first_request(self): <m...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/957f48a98dd7d598c55a521967a2fddcd12a4efd
flask/app.py
"""Create the Jinja environment based on :attr:`jinja_options` and the various Jinja-related methods of the app. Changing :attr:`jinja_options` after this will have no effect. Also adds Flask-related globals and filters to the environment.
<mask> ) <mask> del _get_templates_auto_reload, _set_templates_auto_reload <mask> <mask> def create_jinja_environment(self): <mask> """Creates the Jinja2 environment based on :attr:`jinja_options` <mask> and :meth:`select_jinja_autoescape`. Since 0.7 this also adds <mask> th...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/957f48a98dd7d598c55a521967a2fddcd12a4efd
flask/app.py
<mask> and :meth:`select_jinja_autoescape`. Since 0.7 this also adds <mask> the Jinja2 globals and filters after initialization. Override <mask> this function to customize the behavior. <mask> <mask> .. versionadded:: 0.5 <mask> .. versionchanged:: 0.11 <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/957f48a98dd7d598c55a521967a2fddcd12a4efd
flask/app.py
.. versionadded:: 0.5
<mask> <mask> .. versionchanged:: 0.11 <mask> ``Environment.auto_reload`` set in accordance with <mask> ``TEMPLATES_AUTO_RELOAD`` configuration option. <mask> """ <mask> options = dict(self.jinja_options) <mask> <mask> if "autoescape" not in options: </s>...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/957f48a98dd7d598c55a521967a2fddcd12a4efd
flask/app.py
self._loaded_plugin_commands = False def _load_plugin_commands(self): if self._loaded_plugin_commands: return try: import pkg_resources except ImportError: self._loaded_plugin_commands = True return for ep in pkg_resources.ite...
<mask> if add_default_commands: <mask> self.add_command(run_command) <mask> self.add_command(shell_command) <mask> <mask> def get_command(self, ctx, name): <mask> self._load_plugin_commands() <mask> <mask> # We load built-in commands first as these should al...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9594876c1f6377a3f8b911d31e8c941295baa281
flask/cli.py
self._load_plugin_commands()
<mask> <mask> def get_command(self, ctx, name): <mask> # We load built-in commands first as these should always be the <mask> # same no matter what the app does. If the app does want to <mask> # override this it needs to make a custom instance of this group <mask> # and not a...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9594876c1f6377a3f8b911d31e8c941295baa281
flask/cli.py
self._load_plugin_commands()
<mask> pass <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(click.Group.list_commands(self, ctx)) <mask> info = ctx.ensure_object(Scr...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/9594876c1f6377a3f8b911d31e8c941295baa281
flask/cli.py
def setup(): from ..exthook import ExtensionImporter importer = ExtensionImporter(['flask_%s', 'flaskext.%s'], __name__) importer.install()
<mask> :license: BSD, see LICENSE for more details. <mask> """ <mask> <mask> <mask> class _ExtensionImporter(object): <mask> """This importer redirects imports from this submodule to other locations. <mask> This makes it possible to transition from the old flaskext.name to the <mask> newer fla...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/95c4dcb4d50e69b927855cd6a446579d2fe45b4e
flask/ext/__init__.py
<mask> newer flask_name without people having a hard time. <mask> """ <mask> _module_choices = ['flask_%s', 'flaskext.%s'] <mask> <mask> def __init__(self): <mask> from sys import meta_path <mask> self.prefix = __name__ + '.' <mask> self.prefix_cutoff = __name__.count('....
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/95c4dcb4d50e69b927855cd6a446579d2fe45b4e
flask/ext/__init__.py
setup() del setup
<mask> from sys import meta_path <mask> self.prefix = __name__ + '.' <mask> self.prefix_cutoff = __name__.count('.') + 1 <mask> <mask> # since people might reload the flask.ext module (by accident or <mask> # intentionally) we have to make sure to not add more than one <m...
[ "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/95c4dcb4d50e69b927855cd6a446579d2fe45b4e
flask/ext/__init__.py
if cls.__module__ == 'flask.exthook' and \ cls.__name__ == 'ExtensionImporter':
<mask> # reloading must not add more hooks <mask> import_hooks = 0 <mask> for item in sys.meta_path: <mask> cls = type(item) <mask> if cls.__module__ == 'flask.ext' and \ <mask> cls.__name__ == '_ExtensionImporter': <mask> import_hook...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/95c4dcb4d50e69b927855cd6a446579d2fe45b4e
flask/testsuite/ext.py
def test_no_error_swallowing(self): try: import flask.ext.broken except ImportError: exc_type, exc_value, tb = sys.exc_info() self.assert_(exc_type is ImportError) self.assert_equal(str(exc_value), 'No module named missing_module') self.ass...
<mask> import flask.ext.broken <mask> <mask> <mask> def suite(): <mask> suite = unittest.TestSuite() <mask> suite.addTest(unittest.makeSuite(ExtImportHookTestCase)) </s> Refactored flask.ext process to not swallow exceptions on weird Pythons. </s> remove if hasattr(flask, 'ext'): ...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/95c4dcb4d50e69b927855cd6a446579d2fe45b4e
flask/testsuite/ext.py
import os
<mask> :copyright: (c) 2011 by Armin Ronacher. <mask> :license: BSD, see LICENSE for more details. <mask> """ <mask> import sys <mask> import imp <mask> <mask> <mask> class ExtensionImporter(object): </s> Refactored flask.ext process to not swallow exceptions on weird Pythons. </s> remove class _Exte...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/95c4dcb4d50e69b927855cd6a446579d2fe45b4e
scripts/flaskext_compat.py
class ExtensionImporter(object): """This importer redirects imports from this submodule to other locations. This makes it possible to transition from the old flaskext.name to the newer flask_name without people having a hard time. """
<mask> import sys <mask> import imp <mask> <mask> <mask> ext_module = imp.new_module('flask.ext') <mask> ext_module.__path__ = [] <mask> ext_module.__package__ = ext_module.__name__ <mask> <mask> <mask> class _ExtensionImporter(object): <mask> """This importer redirects imports from the flask.ext mod...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/95c4dcb4d50e69b927855cd6a446579d2fe45b4e
scripts/flaskext_compat.py
def __init__(self, module_choices, wrapper_module): self.module_choices = module_choices self.wrapper_module = wrapper_module self.prefix = wrapper_module + '.' self.prefix_cutoff = wrapper_module.count('.') + 1
<mask> This makes it possible to transition from the old flaskext.name to the <mask> newer flask_name without people having a hard time. <mask> """ <mask> <mask> <mask> def __eq__(self, other): <mask> return self.__class__.__module__ == other.__class__.__module__ and \ <mask> ...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/95c4dcb4d50e69b927855cd6a446579d2fe45b4e
scripts/flaskext_compat.py
def __eq__(self, other): return self.__class__.__module__ == other.__class__.__module__ and \ self.__class__.__name__ == other.__class__.__name__ and \ self.wrapper_module == other.wrapper_module and \ self.module_choices == other.module_choices def __ne__(s...
<mask> ext_module.__path__ = [] <mask> ext_module.__package__ = ext_module.__name__ <mask> <mask> <mask> class _ExtensionImporter(object): <mask> """This importer redirects imports from the flask.ext module to other <mask> locations. For implementation details see the code in Flask 0.8 <mask> tha...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/95c4dcb4d50e69b927855cd6a446579d2fe45b4e
scripts/flaskext_compat.py
for path in self.module_choices:
<mask> def load_module(self, fullname): <mask> if fullname in sys.modules: <mask> return sys.modules[fullname] <mask> modname = fullname.split('.', self.prefix_cutoff)[self.prefix_cutoff] <mask> for path in self._module_choices: <mask> realname = path % modname ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/95c4dcb4d50e69b927855cd6a446579d2fe45b4e
scripts/flaskext_compat.py
# since we only establish the entry in sys.modules at the # very this seems to be redundant, but if recursive imports # happen we will call into the move import a second time. # On the second invocation we still don't have an entry for # fu...
<mask> try: <mask> __import__(realname) <mask> except ImportError: <mask> exc_type, exc_value, tb = sys.exc_info() <mask> sys.modules.pop(fullname, None) <mask> <mask> # If it's an important traceback we reraise it, otherwis...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/95c4dcb4d50e69b927855cd6a446579d2fe45b4e
scripts/flaskext_compat.py
# If it's an important traceback we reraise it, otherwise # we swallow it and try the next choice. The skipped frame # is the one from __import__ above which we don't care about
<mask> # invocation now will have created a fullname entry in <mask> # sys.modules which we have to kill. <mask> sys.modules.pop(fullname, None) <mask> if self.is_important_traceback(realname, tb): <mask> raise exc_type, exc_value,...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/pallets/flask/commit/95c4dcb4d50e69b927855cd6a446579d2fe45b4e
scripts/flaskext_compat.py