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 |
|---|---|---|---|---|
def decorator(
f: "ErrorHandlerCallable[Exception]",
) -> "ErrorHandlerCallable[Exception]": | <mask> """Like :meth:`Flask.errorhandler` but for a blueprint. This
<mask> handler is used for all requests, even if outside of the blueprint.
<mask> """
<mask>
<mask> def decorator(f: ErrorHandlerCallable) -> ErrorHandlerCallable:
<mask> self.record_once(lambda s: s.... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6a4e7e948d7e5bd5b2b76c1b7f1a0392644bee1e | src/flask/blueprints.py |
from .typing import GenericException | <mask> from .templating import _default_template_ctx_processor
<mask> from .typing import AfterRequestCallable
<mask> from .typing import AppOrBlueprintKey
<mask> from .typing import BeforeRequestCallable
<mask> from .typing import ErrorHandlerCallable
<mask> from .typing import TeardownCallable
<mask> from .typ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6a4e7e948d7e5bd5b2b76c1b7f1a0392644bee1e | src/flask/scaffold.py |
from .typing import ErrorHandlerCallable | <mask>
<mask> if t.TYPE_CHECKING:
<mask> from .wrappers import Response
<mask>
<mask> # a singleton sentinel value for parameter defaults
<mask> _sentinel = object()
<mask>
</s> improve typing for `app.errorhandler` decorator </s> remove def _find_error_handler(self, e: Exception) -> t.Optional[Error... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6a4e7e948d7e5bd5b2b76c1b7f1a0392644bee1e | src/flask/scaffold.py |
t.Dict[
t.Optional[int],
t.Dict[t.Type[Exception], "ErrorHandlerCallable[Exception]"],
], | <mask> #: This data structure is internal. It should not be modified
<mask> #: directly and its format may change at any time.
<mask> self.error_handler_spec: t.Dict[
<mask> AppOrBlueprintKey,
<mask> t.Dict[t.Optional[int], t.Dict[t.Type[Exception], ErrorHandlerCalla... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6a4e7e948d7e5bd5b2b76c1b7f1a0392644bee1e | src/flask/scaffold.py |
self, code_or_exception: t.Union[t.Type[GenericException], int]
) -> t.Callable[
["ErrorHandlerCallable[GenericException]"],
"ErrorHandlerCallable[GenericException]",
]: | <mask> return f
<mask>
<mask> @setupmethod
<mask> def errorhandler(
<mask> self, code_or_exception: t.Union[t.Type[Exception], int]
<mask> ) -> t.Callable[[ErrorHandlerCallable], ErrorHandlerCallable]:
<mask> """Register a function to handle errors by code or exception class.... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6a4e7e948d7e5bd5b2b76c1b7f1a0392644bee1e | src/flask/scaffold.py |
def decorator(
f: "ErrorHandlerCallable[GenericException]",
) -> "ErrorHandlerCallable[GenericException]": | <mask> :param code_or_exception: the code as integer for the handler, or
<mask> an arbitrary exception
<mask> """
<mask>
<mask> def decorator(f: ErrorHandlerCallable) -> ErrorHandlerCallable:
<mask> self.register_error_handler(code_or_exceptio... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6a4e7e948d7e5bd5b2b76c1b7f1a0392644bee1e | src/flask/scaffold.py |
code_or_exception: t.Union[t.Type[GenericException], int],
f: "ErrorHandlerCallable[GenericException]", | <mask>
<mask> @setupmethod
<mask> def register_error_handler(
<mask> self,
<mask> code_or_exception: t.Union[t.Type[Exception], int],
<mask> f: ErrorHandlerCallable,
<mask> ) -> None:
<mask> """Alternative error attach function to the :meth:`errorhandler`
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6a4e7e948d7e5bd5b2b76c1b7f1a0392644bee1e | src/flask/scaffold.py |
self.error_handler_spec[None][code][exc_class] = t.cast(
"ErrorHandlerCallable[Exception]", f
) | <mask> " code. Use a subclass of HTTPException with that code"
<mask> " instead."
<mask> )
<mask>
<mask> self.error_handler_spec[None][code][exc_class] = f
<mask>
<mask> @staticmethod
<mask> def _get_exc_class_and_code(
<mask> exc_class_or_c... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6a4e7e948d7e5bd5b2b76c1b7f1a0392644bee1e | src/flask/scaffold.py |
GenericException = t.TypeVar("GenericException", bound=Exception, contravariant=True)
| <mask> t.Tuple[ResponseValue, StatusCode, HeadersValue],
<mask> "WSGIApplication",
<mask> ]
<mask>
<mask> AppOrBlueprintKey = t.Optional[str] # The App key is None, whereas blueprints are named
<mask> AfterRequestCallable = t.Callable[["Response"], "Response"]
<mask> BeforeFirstRequestCallable = t.Call... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6a4e7e948d7e5bd5b2b76c1b7f1a0392644bee1e | src/flask/typing.py |
<mask> AppOrBlueprintKey = t.Optional[str] # The App key is None, whereas blueprints are named
<mask> AfterRequestCallable = t.Callable[["Response"], "Response"]
<mask> BeforeFirstRequestCallable = t.Callable[[], None]
<mask> BeforeRequestCallable = t.Callable[[], t.Optional[ResponseReturnValue]]
<mask> ErrorHand... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6a4e7e948d7e5bd5b2b76c1b7f1a0392644bee1e | src/flask/typing.py | |
app = Flask('flaskr') | <mask> from flaskr.blueprints.flaskr import init_db
<mask>
<mask>
<mask> def create_app(config=None):
<mask> app = Flask(__name__.split('.')[0])
<mask>
<mask> app.config.update(dict(
<mask> DATABASE=os.path.join(app.root_path, 'flaskr.db'),
<mask> DEBUG=True,
<mask> SECRET_K... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6a8c8c34844334d62bf56258cb0390f5999074c7 | examples/flaskr/flaskr/factory.py |
app = Flask('minitwit') | <mask> DEBUG = True
<mask> SECRET_KEY = 'development key'
<mask>
<mask> # create our little application :)
<mask> app = Flask(__name__)
<mask> app.config.from_object(__name__)
<mask> app.config.from_envvar('MINITWIT_SETTINGS', silent=True)
<mask>
<mask>
<mask> def get_db():
</s> set example app names dire... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6a8c8c34844334d62bf56258cb0390f5999074c7 | examples/minitwit/minitwit/minitwit.py |
app = Flask('yourapplication') | <mask> from flask import Flask
<mask> app = Flask(__name__)
<mask>
<mask> import yourapplication.views </s> set example app names directly </s> remove import yourapplication.views </s> add </s> remove app = Flask(__name__.split('.')[0])
</s> add app = Flask('flaskr') </s> remove app = Flask(__name__)
</... | [
"keep",
"replace",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6a8c8c34844334d62bf56258cb0390f5999074c7 | examples/patterns/largerapp/yourapplication/__init__.py |
<mask> from flask import Flask
<mask> app = Flask(__name__)
<mask>
<mask> import yourapplication.views </s> set example app names directly </s> remove app = Flask(__name__)
</s> add app = Flask('yourapplication') </s> remove app = Flask(__name__.split('.')[0])
</s> add app = Flask('flaskr') </s> remove a... | [
"keep",
"keep",
"keep",
"replace"
] | https://github.com/pallets/flask/commit/6a8c8c34844334d62bf56258cb0390f5999074c7 | examples/patterns/largerapp/yourapplication/__init__.py | |
import yourapplication.views | <mask> from flask import Flask
<mask> app = Flask('yourapplication')
<mask>
<mask> import yourapplication.views
</s> set example app names directly </s> remove import yourapplication.views </s> add </s> remove app = Flask(__name__)
</s> add app = Flask('yourapplication') </s> remove app = Flask(__name__.spl... | [
"keep",
"keep",
"keep",
"add"
] | https://github.com/pallets/flask/commit/6a8c8c34844334d62bf56258cb0390f5999074c7 | examples/patterns/largerapp/yourapplication/__init__.py |
# This is not the best way to deal with this but currently the
# underlying Werkzeug router does not support overriding the scheme on
# a per build call basis.
old_scheme = None | <mask> appctx.app.inject_url_defaults(endpoint, values)
<mask>
<mask> if scheme is not None:
<mask> if not external:
<mask> raise ValueError('When specifying _scheme, _external must be True')
<mask> old_scheme = url_adapter.url_scheme
</s> Resolve state issue for url_for with... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6aee9f6d77e0696bd570d6095445d73c48539f8a | flask/helpers.py |
old_scheme = url_adapter.url_scheme | <mask> if not external:
<mask> raise ValueError('When specifying _scheme, _external must be True')
<mask> url_adapter.url_scheme = scheme
<mask>
<mask> try:
<mask> try:
<mask> rv = url_adapter.build(endpoint, values, method=method,
</s> Resolve state issue fo... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6aee9f6d77e0696bd570d6095445d73c48539f8a | flask/helpers.py |
try:
rv = url_adapter.build(endpoint, values, method=method,
force_external=external)
finally:
if old_scheme is not None:
url_adapter.url_scheme = old_scheme | <mask> raise ValueError('When specifying _scheme, _external must be True')
<mask> url_adapter.url_scheme = scheme
<mask>
<mask> try:
<mask> rv = url_adapter.build(endpoint, values, method=method,
<mask> force_external=external)
<mask> except Bui... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6aee9f6d77e0696bd570d6095445d73c48539f8a | flask/helpers.py |
def test_url_for_with_alternating_schemes(self):
app = flask.Flask(__name__)
@app.route('/')
def index():
return '42'
with app.test_request_context():
assert flask.url_for('index', _external=True) == 'http://localhost/'
assert flask.url_for('index'... | <mask> 'index',
<mask> _scheme='https')
<mask>
<mask> def test_url_with_method(self):
<mask> from flask.views import MethodView
<mask> app = flask.Flask(__name__)
<mask> class MyView(MethodView):
<mask> def ge... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6aee9f6d77e0696bd570d6095445d73c48539f8a | tests/test_helpers.py |
In `flaskr.py`:: | <mask> into the module which we will be doing here. However a cleaner solution
<mask> would be to create a separate `.ini` or `.py` file and load that or import
<mask> the values from there.
<mask>
<mask> ::
<mask>
<mask> # all the imports
<mask> import sqlite3
<mask> from flask import Flask, re... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6b9e6a5a52f22bdf6b86b76de1fc7c8e1a635a8f | docs/tutorial/setup.rst |
config from the same file, in `flaskr.py`:: | <mask> USERNAME = 'admin'
<mask> PASSWORD = 'default'
<mask>
<mask> Next we can create our actual application and initialize it with the
<mask> config from the same file::
<mask>
<mask> # create our little application :)
<mask> app = Flask(__name__)
<mask> app.config.from_object(__name__)... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6b9e6a5a52f22bdf6b86b76de1fc7c8e1a635a8f | docs/tutorial/setup.rst |
Usually, it is a good idea to load a configuration from a configurable
file. This is what :meth:`~flask.Config.from_envvar` can do, replacing the
:meth:`~flask.Config.from_object` line above:: | <mask> string it will import it) and then look for all uppercase variables
<mask> defined there. In our case, the configuration we just wrote a few lines
<mask> of code above. You can also move that into a separate file.
<mask>
<mask> It is also a good idea to be able to load a configuration from a
<mask> conf... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6b9e6a5a52f22bdf6b86b76de1fc7c8e1a635a8f | docs/tutorial/setup.rst |
:envvar:`FLASKR_SETTINGS` to specify a config file to be loaded which will then
override the default values. The silent switch just tells Flask to not complain
if no such environment key is set. | <mask>
<mask> app.config.from_envvar('FLASKR_SETTINGS', silent=True)
<mask>
<mask> That way someone can set an environment variable called
<mask> :envvar:`FLASKR_SETTINGS` to specify a config file to be loaded which will
<mask> then override the default values. The silent switch just tells Flask to
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6b9e6a5a52f22bdf6b86b76de1fc7c8e1a635a8f | docs/tutorial/setup.rst |
debug flag enables or disables the interactive debugger. *Never leave
debug mode activated in a production system*, because it will allow users to | <mask> not complain if no such environment key is set.
<mask>
<mask> The `secret_key` is needed to keep the client-side sessions secure.
<mask> Choose that key wisely and as hard to guess and complex as possible. The
<mask> debug flag enables or disables the interactive debugger. Never leave
<mask> debug mode ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6b9e6a5a52f22bdf6b86b76de1fc7c8e1a635a8f | docs/tutorial/setup.rst |
from . import __version__ | <mask> import click
<mask>
<mask> from ._compat import iteritems, reraise
<mask> from .helpers import get_debug_flag
<mask>
<mask>
<mask> class NoAppException(click.UsageError):
<mask> """Raised if an application cannot be found or loaded."""
<mask>
<mask>
</s> Add a --version switch to flask cli
re... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6bee3e4995066466a35ac080844d4962a728d084 | flask/cli.py |
def get_version(ctx, param, value):
if not value or ctx.resilient_parsing:
return
message = 'Flask %(version)s\nPython %(python_version)s'
click.echo(message % {
'version': __version__,
'python_version': sys.version[:3],
}, color=ctx.color)
ctx.exit()
version_option = click.... | <mask> return prepare_exec_for_file(app)
<mask> return app
<mask>
<mask>
<mask> class DispatchingApp(object):
<mask> """Special application that dispatches to a flask application which
<mask> is imported by name in a background thread. If an error happens
<mask> it is is recorded and ... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6bee3e4995066466a35ac080844d4962a728d084 | flask/cli.py |
:param add_version_option: adds the :option:`--version` option. | <mask> For information as of why this is useful see :ref:`custom-scripts`.
<mask>
<mask> :param add_default_commands: if this is True then the default run and
<mask> shell commands wil be added.
<mask> :param create_app: an optional callback that is passed the script i... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6bee3e4995066466a35ac080844d4962a728d084 | flask/cli.py |
def __init__(self, add_default_commands=True, create_app=None,
add_version_option=True, **extra):
params = list(extra.pop('params', None) or ())
if add_version_option:
params.append(version_option)
AppGroup.__init__(self, params=params, **extra) | <mask> :param create_app: an optional callback that is passed the script info
<mask> and returns the loaded app.
<mask> """
<mask>
<mask> def __init__(self, add_default_commands=True, create_app=None, **extra):
<mask> AppGroup.__init__(self, **extra)
<mask> sel... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6bee3e4995066466a35ac080844d4962a728d084 | flask/cli.py |
if json is not None: | <mask> path = url.path
<mask> if url.query:
<mask> path += '?' + url.query
<mask>
<mask> if json:
<mask> if 'data' in kwargs:
<mask> raise RuntimeError('Client cannot provide both `json` and `data`')
<mask> kwargs['data'] = json_dumps(json... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6c5ef2bc5c7c304c8d4a2ddbb8666167ae73d4c4 | flask/testing.py |
if 'content_type' not in kwargs:
kwargs['content_type'] = 'application/json' | <mask> raise RuntimeError('Client cannot provide both `json` and `data`')
<mask> kwargs['data'] = json_dumps(json)
<mask>
<mask> # Only set Content-Type when not explicitly provided
<mask> if 'Content-Type' not in kwargs.get('headers', {}):
<mask> new_headers = kwa... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6c5ef2bc5c7c304c8d4a2ddbb8666167ae73d4c4 | flask/testing.py |
assert flask.request.is_json | <mask> rv = c.post('/api', json=json_data)
<mask> assert rv.status_code == 200
<mask> assert flask.request.get_json() == json_data
<mask>
<mask> def test_subdomain():
<mask> app = flask.Flask(__name__)
</s> Use `content_type` kwarg instead of manipulating headers </s> remove ... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6c5ef2bc5c7c304c8d4a2ddbb8666167ae73d4c4 | tests/test_testing.py |
except Exception as e: | <mask> request_started.send(self)
<mask> rv = self.preprocess_request()
<mask> if rv is None:
<mask> rv = self.dispatch_request()
<mask> except Exception, e:
<mask> rv = self.handle_user_exception(e)
<mask> response = self.make_respo... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/app.py |
except MethodNotAllowed as e: | <mask> # fallback for Werkzeug < 0.7
<mask> methods = []
<mask> try:
<mask> adapter.match(method='--')
<mask> except MethodNotAllowed, e:
<mask> methods = e.valid_methods
<mask> except HTTPException, e:
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/app.py |
except HTTPException as e: | <mask> try:
<mask> adapter.match(method='--')
<mask> except MethodNotAllowed, e:
<mask> methods = e.valid_methods
<mask> except HTTPException, e:
<mask> pass
<mask> rv = self.response_class()
<mask> rv.allow.upda... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/app.py |
except BuildError as error: | <mask> try:
<mask> rv = handler(error, endpoint, values)
<mask> if rv is not None:
<mask> return rv
<mask> except BuildError, error:
<mask> pass
<mask>
<mask> # At this point we want to reraise the exception. I... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/app.py |
except Exception as e: | <mask> """
<mask> with self.request_context(environ):
<mask> try:
<mask> response = self.full_dispatch_request()
<mask> except Exception, e:
<mask> response = self.make_response(self.handle_exception(e))
<mask> return response(en... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/app.py |
except IOError as e: | <mask> d = imp.new_module('config')
<mask> d.__file__ = filename
<mask> try:
<mask> execfile(filename, d.__dict__)
<mask> except IOError, e:
<mask> if silent and e.errno in (errno.ENOENT, errno.EISDIR):
<mask> return False
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/config.py |
except HTTPException as e: | <mask> try:
<mask> url_rule, self.request.view_args = \
<mask> self.url_adapter.match(return_rule=True)
<mask> self.request.url_rule = url_rule
<mask> except HTTPException, e:
<mask> self.request.routing_exception = e
<mask>
<mask> def pus... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/ctx.py |
except KeyError as e: | <mask> class newcls(oldcls):
<mask> def __getitem__(self, key):
<mask> try:
<mask> return oldcls.__getitem__(self, key)
<mask> except KeyError, e:
<mask> if key not in request.form:
<mask> raise
<mask> raise ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/debughelpers.py |
except BuildError as error: | <mask>
<mask> try:
<mask> rv = url_adapter.build(endpoint, values, method=method,
<mask> force_external=external)
<mask> except BuildError, error:
<mask> # We need to inject the values again so that the app callback can
<mask> # deal with that sort ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/helpers.py |
except Exception as e: | <mask> def main():
<mask> """Runs the testsuite as command line application."""
<mask> try:
<mask> unittest.main(testLoader=BetterLoader(), defaultTest='suite')
<mask> except Exception, e:
<mask> print 'Error: %s' % e
</s> automated change using python-modernize: use 'as' in except </... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/testsuite/__init__.py |
except RuntimeError as e: | <mask> app = flask.Flask(__name__)
<mask> def expect_exception(f, *args, **kwargs):
<mask> try:
<mask> f(*args, **kwargs)
<mask> except RuntimeError, e:
<mask> self.assert_(e.args and 'session is unavailable' in e.args[0])
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/testsuite/basic.py |
except BuildError as error: | <mask> # Verify the error is re-raised if not the current exception.
<mask> try:
<mask> with app.test_request_context():
<mask> flask.url_for('spam')
<mask> except BuildError, error:
<mask> pass
<mask> try:
<mask> raise RuntimeE... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/testsuite/basic.py |
except ValueError as e: | <mask> def test():
<mask> return None
<mask> try:
<mask> app.test_client().get('/')
<mask> except ValueError, e:
<mask> self.assert_equal(str(e), 'View function did not return a response')
<mask> pass
<mask> else:
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/testsuite/basic.py |
except ValueError as e: | <mask> app.config.update(SERVER_NAME='localhost.localdomain:443')
<mask> rv = app.test_client().get('/', 'https://localhost.localdomain')
<mask> # Werkzeug 0.8
<mask> self.assert_equal(rv.status_code, 404)
<mask> except ValueError, e:
<mask> # We... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/testsuite/basic.py |
except ValueError as e: | <mask> app.config.update(SERVER_NAME='localhost.localdomain')
<mask> rv = app.test_client().get('/', 'http://foo.localhost')
<mask> # Werkzeug 0.8
<mask> self.assert_equal(rv.status_code, 404)
<mask> except ValueError, e:
<mask> # Werkzeug 0.7
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/testsuite/basic.py |
except AssertionError as e: | <mask> try:
<mask> @app.route('/foo')
<mask> def broken():
<mask> return 'Meh'
<mask> except AssertionError, e:
<mask> self.assert_('A setup function was called' in str(e))
<mask> else:
<mask> self.fail('Expected exception')... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/testsuite/basic.py |
except AssertionError as e: | <mask> return 'success'
<mask> with app.test_client() as c:
<mask> try:
<mask> c.post('/foo', data={})
<mask> except AssertionError, e:
<mask> self.assert_('http://localhost/foo/' in str(e))
<mask> self.assert_('Make sure... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/testsuite/basic.py |
except TemplateNotFound as e: | <mask>
<mask> with app.test_request_context():
<mask> try:
<mask> flask.render_template('missing.html')
<mask> except TemplateNotFound, e:
<mask> self.assert_equal(e.name, 'missing.html')
<mask> else:
<mask> self.assert... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/testsuite/blueprints.py |
except TemplateNotFound as e: | <mask>
<mask> with app.test_request_context():
<mask> try:
<mask> flask.render_template('missing.html')
<mask> except TemplateNotFound, e:
<mask> self.assert_equal(e.name, 'missing.html')
<mask> else:
<mask> self.assert... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/testsuite/blueprints.py |
except RuntimeError as e: | <mask> os.environ = {}
<mask> app = flask.Flask(__name__)
<mask> try:
<mask> app.config.from_envvar('FOO_SETTINGS')
<mask> except RuntimeError, e:
<mask> self.assert_("'FOO_SETTINGS' is not set" in str(e))
<mask> else:
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/testsuite/config.py |
except IOError as e: | <mask> os.environ = {'FOO_SETTINGS': 'missing.cfg'}
<mask> try:
<mask> app = flask.Flask(__name__)
<mask> app.config.from_envvar('FOO_SETTINGS')
<mask> except IOError, e:
<mask> msg = str(e)
<mask> self.assert_(ms... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/testsuite/config.py |
except IOError as e: | <mask> def test_config_missing(self):
<mask> app = flask.Flask(__name__)
<mask> try:
<mask> app.config.from_pyfile('missing.cfg')
<mask> except IOError, e:
<mask> msg = str(e)
<mask> self.assert_(msg.startswith('[Errno 2] Unable to load configuratio... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/testsuite/config.py |
except ValueError as e: | <mask> def test_explicit_instance_paths(self):
<mask> here = os.path.abspath(os.path.dirname(__file__))
<mask> try:
<mask> flask.Flask(__name__, instance_path='instance')
<mask> except ValueError, e:
<mask> self.assert_('must be absolute' in str(e))
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/testsuite/config.py |
except Exception as e: | <mask>
<mask> try:
<mask> with app.test_request_context('/', environ_overrides={'HTTP_HOST': 'localhost'}):
<mask> pass
<mask> except Exception, e:
<mask> self.assert_(isinstance(e, ValueError))
<mask> self.assert_equal(str(e), "the server name... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/testsuite/reqctx.py |
except ValueError as e: | <mask> try:
<mask> app.config.update(SERVER_NAME='localhost')
<mask> with app.test_request_context('/', environ_overrides={'SERVER_NAME': 'localhost'}):
<mask> pass
<mask> except ValueError, e:
<mask> raise ValueError(
<mask> "No... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/testsuite/reqctx.py |
except ValueError as e: | <mask> try:
<mask> app.config.update(SERVER_NAME='localhost:80')
<mask> with app.test_request_context('/', environ_overrides={'SERVER_NAME': 'localhost:80'}):
<mask> pass
<mask> except ValueError, e:
<mask> raise ValueError(
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/testsuite/reqctx.py |
except RuntimeError as e: | <mask> with app.test_client() as c:
<mask> try:
<mask> with c.session_transaction() as sess:
<mask> pass
<mask> except RuntimeError, e:
<mask> self.assert_('Session backend did not open a session' in str(e))
<mask> el... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/testsuite/testing.py |
except RuntimeError as e: | <mask> c = app.test_client(use_cookies=False)
<mask> try:
<mask> with c.session_transaction() as s:
<mask> pass
<mask> except RuntimeError, e:
<mask> self.assert_('cookies' in str(e))
<mask> else:
<mask> self.fail('Expected runt... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/testsuite/testing.py |
except ValueError as e: | <mask> try:
<mask> if request_charset is not None:
<mask> return json.loads(self.data, encoding=request_charset)
<mask> return json.loads(self.data)
<mask> except ValueError, e:
<mask> return self.on_json_loading_failed(e)... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6caaa8a527134dc9aff6d5c442969e96f9c00f21 | flask/wrappers.py |
_render_template_re = re.compile(r'\b(render_template\()(%s)' % _string_re_part) | <mask> r'|"([^"\\]*(?:\\.[^"\\]*)*)")'
<mask> _url_for_re = re.compile(r'\b(url_for\()(%s)' % _string_re_part)
<mask> _after_request_re = re.compile(r'((?:@\S+\.(?:app_)?))(after_request)(\b\s*$)(?m)')
<mask> _module_constructor_re = re.compile(r'([a-zA-Z0-9_][a-zA-Z0-9_]*)\s*=\s*Module'
<mask> ... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d072f00adb12569380becd17f277b5456ad07c0 | scripts/flask-07-upgrade.py |
_module_constructor_re = re.compile(r'([a-zA-Z0-9_][a-zA-Z0-9_]*)\s*=\s*Module'
r'\(__name__\s*(?:,\s*(%s))?' % | <mask> _string_re_part = r"('([^'\\]*(?:\\.[^'\\]*)*)'" \
<mask> r'|"([^"\\]*(?:\\.[^"\\]*)*)")'
<mask> _url_for_re = re.compile(r'\b(url_for\()(%s)' % _string_re_part)
<mask> _after_request_re = re.compile(r'((?:@\S+\.(?:app_)?))(after_request)(\b\s*$)(?m)')
<mask> _module_constructor_re = re.co... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d072f00adb12569380becd17f277b5456ad07c0 | scripts/flask-07-upgrade.py |
_mod_route_re = re.compile(r'([a-zA-Z0-9_][a-zA-Z0-9_]*)\.route') | <mask> _module_constructor_re = re.compile(r'([a-zA-Z0-9_][a-zA-Z0-9_]*)\s*=\s*Module'
<mask> r'\(__name__\s*(?:,\s*(%s))?' %
<mask> _string_re_part)
<mask> _blueprint_related = [
<mask> (re.compile(r'request\.module'), 'request.blueprint'... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d072f00adb12569380becd17f277b5456ad07c0 | scripts/flask-07-upgrade.py |
def rewrite_render_template_calls(contents, module_declarations):
mapping = dict(module_declarations)
annotated_lines = []
def make_line_annotations():
if not annotated_lines:
last_index = 0
for line in contents.splitlines(True):
last_index += len(line)
... | <mask> new_file.append(line)
<mask> return ''.join(new_file)
<mask>
<mask>
<mask> def rewrite_for_blueprints(contents, filename):
<mask> found_constructor = []
<mask> def handle_match(match):
<mask> found_constructor[:] = [True]
<mask> name_param = match.group(1)
<mas... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d072f00adb12569380becd17f277b5456ad07c0 | scripts/flask-07-upgrade.py |
target = match.group(1)
name_param = match.group(2) | <mask>
<mask> def rewrite_for_blueprints(contents, filename):
<mask> found_constructor = []
<mask> def handle_match(match):
<mask> found_constructor[:] = [True]
<mask> name_param = match.group(1)
<mask> if name_param is None:
<mask> return 'Blueprint(%r, __name__' % ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d072f00adb12569380becd17f277b5456ad07c0 | scripts/flask-07-upgrade.py |
modname = get_module_autoname(filename)
else:
modname = ast.literal_eval(name_param)
modules_declared.append((target, modname))
return '%s = %s' % (target, 'Blueprint(%r, __name__' % modname) | <mask> def handle_match(match):
<mask> found_constructor[:] = [True]
<mask> name_param = match.group(1)
<mask> if name_param is None:
<mask> return 'Blueprint(%r, __name__' % get_module_autoname(filename)
<mask> return 'Blueprint(%s, __name__' % name_param
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d072f00adb12569380becd17f277b5456ad07c0 | scripts/flask-07-upgrade.py |
if modules_declared: | <mask> return 'Blueprint(%r, __name__' % get_module_autoname(filename)
<mask> return 'Blueprint(%s, __name__' % name_param
<mask> new_contents = _module_constructor_re.sub(handle_match, contents)
<mask>
<mask> if found_constructor:
<mask> new_contents = rewrite_blueprint_impor... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d072f00adb12569380becd17f277b5456ad07c0 | scripts/flask-07-upgrade.py |
if template_bundles:
new_contents = rewrite_render_template_calls(new_contents,
modules_declared) | <mask>
<mask> if modules_declared:
<mask> new_contents = rewrite_blueprint_imports(new_contents)
<mask>
<mask> for pattern, replacement in _blueprint_related:
<mask> new_contents = pattern.sub(replacement, new_contents)
<mask> return new_contents
<mask>
</s> Better control over t... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d072f00adb12569380becd17f277b5456ad07c0 | scripts/flask-07-upgrade.py |
def upgrade_python_file(filename, contents, teardown, template_bundles): | <mask> new_contents = pattern.sub(replacement, new_contents)
<mask> return new_contents
<mask>
<mask>
<mask> def upgrade_python_file(filename, contents, teardown):
<mask> new_contents = fix_url_for(contents)
<mask> if teardown:
<mask> new_contents = fix_teardown_funcs(new_contents)... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d072f00adb12569380becd17f277b5456ad07c0 | scripts/flask-07-upgrade.py |
new_contents = rewrite_for_blueprints(new_contents, filename,
template_bundles) | <mask> def upgrade_python_file(filename, contents, teardown):
<mask> new_contents = fix_url_for(contents)
<mask> if teardown:
<mask> new_contents = fix_teardown_funcs(new_contents)
<mask> new_contents = rewrite_for_blueprints(new_contents, filename)
<mask> make_diff(filename, contents, new... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d072f00adb12569380becd17f277b5456ad07c0 | scripts/flask-07-upgrade.py |
def walk_path(path): | <mask> new_contents = fix_url_for(contents)
<mask> make_diff(filename, contents, new_contents)
<mask>
<mask>
<mask> def scan_path(path=None, teardown=True):
<mask> for dirpath, dirnames, filenames in os.walk(path):
<mask> for filename in filenames:
<mask> filename = os.path.joi... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d072f00adb12569380becd17f277b5456ad07c0 | scripts/flask-07-upgrade.py |
<mask> def scan_path(path=None, teardown=True):
<mask> for dirpath, dirnames, filenames in os.walk(path):
<mask> for filename in filenames:
<mask> filename = os.path.join(dirpath, filename)
<mask> with open(filename) as f:
<mask> contents = f.read()
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d072f00adb12569380becd17f277b5456ad07c0 | scripts/flask-07-upgrade.py | |
yield filename, 'python'
else:
with open(filename) as f:
contents = f.read()
if '{% for' or '{% if' or '{{ url_for' in contents:
yield filename, 'template'
def scan_path(path=None, teardown=True, template_bundles=True)... | <mask> filename = os.path.join(dirpath, filename)
<mask> with open(filename) as f:
<mask> contents = f.read()
<mask> if filename.endswith('.py'):
<mask> upgrade_python_file(filename, contents, teardown)
<mask> elif '{% for' or '{% if'... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d072f00adb12569380becd17f277b5456ad07c0 | scripts/flask-07-upgrade.py |
parser.add_option('-b', '--bundled-templates', dest='bundled_tmpl',
action='store_true', help='Indicate to the system '
'that templates are bundled with modules. Default '
'is auto detect.')
parser.add_option('-B', '--no-bundled-templates', dest... | <mask> action='store_true', help='Do not attempt to '
<mask> 'detect teardown function rewrites.')
<mask> options, args = parser.parse_args()
<mask> if not args:
<mask> args = ['.']
<mask>
<mask> if options.no_bundled_tmpl:
<mask> template... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d072f00adb12569380becd17f277b5456ad07c0 | scripts/flask-07-upgrade.py |
if options.no_bundled_tmpl:
template_bundles = False
elif options.bundled_tmpl:
template_bundles = True
else:
template_bundles = autodetect_template_bundles(args)
| <mask> if not args:
<mask> args = ['.']
<mask>
<mask> for path in args:
<mask> scan_path(path, teardown=not options.no_teardown,
<mask> template_bundles=template_bundles)
<mask>
<mask>
<mask> if __name__ == '__main__':
</s> Better control over template rendering ca... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d072f00adb12569380becd17f277b5456ad07c0 | scripts/flask-07-upgrade.py |
scan_path(path, teardown=not options.no_teardown,
template_bundles=template_bundles) | <mask> if not args:
<mask> args = ['.']
<mask>
<mask> for path in args:
<mask> scan_path(path, teardown=not options.no_teardown)
<mask>
<mask>
<mask> if __name__ == '__main__':
<mask> main()
</s> Better control over template rendering calls </s> remove upgrade_py... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d072f00adb12569380becd17f277b5456ad07c0 | scripts/flask-07-upgrade.py |
except Exception as e: | <mask> def wsgi_app(self, environ):
<mask> with self.request_context(environ):
<mask> try:
<mask> response = self.full_dispatch_request()
<mask> except Exception, e:
<mask> response = self.make_response(self.handle_exception(e))
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d0bbd627c8ff7b6339c894342d00eae11deb7ec | docs/reqcontext.rst |
#: example be used to close database connections or getting hold of the | <mask>
<mask> #: A dictionary with lists of functions that should be called after
<mask> #: each request. The key of the dictionary is the name of the blueprint
<mask> #: this function is active for, ``None`` for all requests. This can for
<mask> #: example be used to open databa... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d0bbd627c8ff7b6339c894342d00eae11deb7ec | flask/app.py |
The resulting dictionary `image_store_config` would look like:: | <mask> app.config['IMAGE_STORE_PATH'] = '/var/app/images'
<mask> app.config['IMAGE_STORE_BASE_URL'] = 'http://img.website.com'
<mask> image_store_config = app.config.get_namespace('IMAGE_STORE_')
<mask>
<mask> The resulting dictionary `image_store` would look like::
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d0bbd627c8ff7b6339c894342d00eae11deb7ec | flask/config.py |
'http://werkzeug.pocoo.org/documentation/dev/': None,
'http://www.sqlalchemy.org/docs/': None | <mask> #epub_tocdepth = 3
<mask>
<mask> intersphinx_mapping = {
<mask> 'http://docs.python.org/dev': None,
<mask> 'http://werkzeug.pocoo.org/documentation/dev/': None
<mask> }
</s> added coming soon to parts of the docs, linked scoped_session </s> remove the code above.
</s> add the code above. If you... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep"
] | https://github.com/pallets/flask/commit/6d556acb3fcaa6eeff4bda8cf704ad5f0cf5b5ac | docs/conf.py |
the code above. If you are wondering why we don't have to care about
threads here (like we did in the SQLite3 example above with the
:data:`~flask.g` object): that's because SQLAlchemy does that for us
already with the :class:`~sqlalchemy.orm.scoped_session`. | <mask> def init_db():
<mask> Base.metadata.create_all(bind=engine)
<mask>
<mask> To define your models, just subclass the `Base` class that was created by
<mask> the code above.
<mask>
<mask> To use SQLAlchemy in a declarative way with your application, you just
<mask> have to put the following co... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d556acb3fcaa6eeff4bda8cf704ad5f0cf5b5ac | docs/patterns.rst |
Manual Object Relational Mapping
--------------------------------
*coming soon*
SQL Abstraction Layer
---------------------
*coming soon*
| <mask> .. _declarative:
<mask> http://www.sqlalchemy.org/docs/reference/ext/declarative.html
<mask>
<mask>
<mask> .. _template-inheritance:
<mask>
<mask> Template Inheritance
<mask> --------------------
<mask>
</s> added coming soon to parts of the docs, linked scoped_session </s> remove the code above... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d556acb3fcaa6eeff4bda8cf704ad5f0cf5b5ac | docs/patterns.rst |
Version 1.1.3 | <mask> .. currentmodule:: flask
<mask>
<mask>
<mask>
<mask> Version 1.1.x
<mask> -------------
<mask>
<mask> Not yet released.
<mask>
<mask> - Officially support passing a :class:`pathlib.Path` for
</s> set maximum versions of pallets dependencies </s> remove Not yet released.
</s> add Unreleased </s... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d8b4ce9d037937ef8694067ab5754666240d097 | CHANGES.rst |
Unreleased | <mask>
<mask> Version 1.1.x
<mask> -------------
<mask>
<mask> Not yet released.
<mask>
<mask> - Officially support passing a :class:`pathlib.Path` for
<mask> ``static_folder`` which stopped working in 1.1.2. :pr:`3579`
<mask>
<mask>
</s> set maximum versions of pallets dependencies </s> remove - ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d8b4ce9d037937ef8694067ab5754666240d097 | CHANGES.rst |
- Set maximum versions of Werkzeug, Jinja, Click, and ItsDangerous.
:issue:`4043`
- Re-add support for passing a ``pathlib.Path`` for ``static_folder``.
:pr:`3579` | <mask> -------------
<mask>
<mask> Not yet released.
<mask>
<mask> - Officially support passing a :class:`pathlib.Path` for
<mask> ``static_folder`` which stopped working in 1.1.2. :pr:`3579`
<mask>
<mask>
<mask> Version 1.1.2
<mask> -------------
<mask>
</s> set maximum versions of pallets depen... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d8b4ce9d037937ef8694067ab5754666240d097 | CHANGES.rst |
"Werkzeug >= 0.15, < 2.0",
"Jinja2 >= 2.10.1, < 3.0",
"itsdangerous >= 0.24, < 2.0",
"click >= 5.1, < 8.0", | <mask> package_dir={"": "src"},
<mask> include_package_data=True,
<mask> python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
<mask> install_requires=[
<mask> "Werkzeug>=0.15",
<mask> "Jinja2>=2.10.1",
<mask> "itsdangerous>=0.24",
<mask> "click>=5... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6d8b4ce9d037937ef8694067ab5754666240d097 | setup.py |
__version__ = "1.1.3.dev0" | <mask> from .signals import template_rendered
<mask> from .templating import render_template
<mask> from .templating import render_template_string
<mask>
<mask> __version__ = "1.1.2"
</s> set maximum versions of pallets dependencies </s> remove "Werkzeug>=0.15",
"Jinja2>=2.10.1",
"itsdang... | [
"keep",
"keep",
"keep",
"keep",
"replace"
] | https://github.com/pallets/flask/commit/6d8b4ce9d037937ef8694067ab5754666240d097 | src/flask/__init__.py |
blueprint_name = request.blueprint | <mask> """
<mask> ctx = _request_ctx_stack.top
<mask> if not ctx.request._is_old_module:
<mask> if endpoint[:1] == '.':
<mask> if blueprint_name is not None:
<mask> endpoint = blueprint_name + endpoint
</s> Started work on an upgrade script for blueprints </s> remo... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6dae36f94db40d242fee73d10467a25cfa90b580 | flask/helpers.py |
if blueprint_name is not None:
endpoint = blueprint_name + endpoint
else:
endpoint = endpoint[1:] | <mask> """
<mask> ctx = _request_ctx_stack.top
<mask> if not ctx.request._is_old_module:
<mask> if endpoint[:1] == '.':
<mask> endpoint = request.blueprint + endpoint
<mask> else:
<mask> # TODO: get rid of this deprecated functionality in 1.0
<mask> if '.' not... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6dae36f94db40d242fee73d10467a25cfa90b580 | flask/helpers.py |
if blueprint_name is not None:
endpoint = blueprint_name + '.' + endpoint | <mask> endpoint = request.blueprint + endpoint
<mask> else:
<mask> # TODO: get rid of this deprecated functionality in 1.0
<mask> if '.' not in endpoint:
<mask> mod = ctx.request.blueprint
<mask> if mod is not None:
<mask> endpoint = mod + '... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6dae36f94db40d242fee73d10467a25cfa90b580 | flask/helpers.py |
.. admonition:: Notice
The ``PERMANENT_SESSION_LIFETIME`` config key can also be an integer
starting with Flask 0.8. Either catch this down yourself or use
the :attr:`~flask.Flask.permanent_session_lifetime` attribute on the
app which converts the result to an integer automatically.
| <mask>
<mask> .. autoclass:: SessionMixin
<mask> :members:
<mask>
<mask>
<mask> Test Client
<mask> -----------
<mask>
<mask> .. currentmodule:: flask.testing
<mask>
</s> PERMANENT_SESSION_LIFETIME can now be an integer. This fixes #310 </s> remove #: A :class:`~datetime.timedelta` which is used ... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6dccf775468ea0a849d3c1c3965e3a1db6a36a3f | docs/api.rst |
Starting with Flask 0.8 this can also be
an integer representing seconds. | <mask> `False`.
<mask> ``PERMANENT_SESSION_LIFETIME`` the lifetime of a permanent session as
<mask> :class:`datetime.timedelta` object.
<mask> ``USE_X_SENDFILE`` enable/disable x-sendfile
<mask> ``LOGGER_NAME`` ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6dccf775468ea0a849d3c1c3965e3a1db6a36a3f | docs/config.rst |
<mask> #: This attribute can also be configured from the config with the
<mask> #: `SESSION_COOKIE_NAME` configuration key. Defaults to ``'session'``
<mask> session_cookie_name = ConfigAttribute('SESSION_COOKIE_NAME')
<mask>
<mask> #: A :class:`~datetime.timedelta` which is used to set the expira... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6dccf775468ea0a849d3c1c3965e3a1db6a36a3f | flask/app.py | |
If the incoming form data was not encoded with a known mimetype
the data is stored unmodified in this stream for consumption. Most
of the time it is a better idea to use :attr:`data` which will give
you that data as a string. The stream only returns the data once.
.. attribute:: data | <mask> the request.
<mask>
<mask> .. attribute:: stream
<mask>
<mask> If the incoming form data was not encoded with a known encoding (for
<mask> example it was transmitted as JSON) the data is stored unmodified in
<mask> this stream for consumption. For example to read the incoming... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6e2be6a0b3aba4ab49cf3ed1a10ac13c6b771aba | docs/api.rst |
Contains the incoming request data as string in case it came with
a mimetype Flask does not handle. | <mask> example it was transmitted as JSON) the data is stored unmodified in
<mask> this stream for consumption. For example to read the incoming
<mask> request data as JSON, one can do the following::
<mask>
<mask> json_body = simplejson.load(request.stream)
<mask>
<mask> .. att... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6e2be6a0b3aba4ab49cf3ed1a10ac13c6b771aba | docs/api.rst |
.. attribute:: is_xhr
`True` if the request was triggered via a JavaScript
`XMLHttpRequest`. This only works with libraries that support the
``X-Requested-With`` header and set it to `XMLHttpRequest`.
Libraries that do that are prototype, jQuery and Mochikit and
probably some more.
... | <mask> ============= ======================================================
<mask>
<mask> Response Objects
<mask> ----------------
<mask>
<mask> .. autoclass:: flask.Response
<mask> :members: set_cookie, data, mimetype
</s> Added JSON Support and started working on jQuery docs </s> remove LocalS... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6e2be6a0b3aba4ab49cf3ed1a10ac13c6b771aba | docs/api.rst |
LocalStack, LocalProxy, create_environ, SharedDataMiddleware, \
cached_property | <mask> import sys
<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> from werkzeug.routing import Map, Rule
<mask> from werkz... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6e2be6a0b3aba4ab49cf3ed1a10ac13c6b771aba | flask.py |
# try to load the best simplejson implementation available. If JSON
# is not installed, we add a failing class.
json_available = True
try:
import simplejson as json
except ImportError:
try:
import json
except ImportError:
json_available = False
| <mask> from werkzeug.exceptions import HTTPException
<mask> from werkzeug.contrib.securecookie import SecureCookie
<mask>
<mask> # utilities we import from Werkzeug and Jinja2 that are unused
<mask> # in the module but are exported as public interface.
<mask> from werkzeug import abort, redirect
<mask> from jin... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6e2be6a0b3aba4ab49cf3ed1a10ac13c6b771aba | flask.py |
@cached_property
def json(self):
"""If the mimetype is `application/json` this will contain the
parsed JSON data.
"""
if not json_available:
raise AttributeError('simplejson not available')
if self.mimetype == 'application/json':
return json.loads(... | <mask> self.view_args = None
<mask>
<mask>
<mask> class Response(ResponseBase):
<mask> """The response object that is used by default in flask. Works like the
<mask> response object from Werkzeug but is set to have a HTML mimetype by
</s> Added JSON Support and started working on jQuery docs <... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6e2be6a0b3aba4ab49cf3ed1a10ac13c6b771aba | flask.py |
.. versionadded:: 0.2
| <mask> return hello('World')
<mask>
<mask> :param template_name: the name of the template
<mask> :param attribute: the name of the variable of macro to acccess
<mask> """
<mask> return getattr(current_app.jinja_env.get_template(template_name).module,
<mask> attribute)
... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/pallets/flask/commit/6e2be6a0b3aba4ab49cf3ed1a10ac13c6b771aba | flask.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.