Skip to content
Myr

Made errors for working outside of contexts clearer.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 5693b9d · Browse files · 1 file+20 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+20 added−3 removed

  • other:+20 added−3 removed

1 file+20 added−3 removed

modified:flask/globals.py+20 added-3 removed
12 unmodified lines
13from functools import partial14from werkzeug.local import LocalStack, LocalProxy151617_request_ctx_err_msg = '''\18Working outside of request context.1920This typically means that you attempted to use functionality that needed21an active HTTP request. Consult the documentation on testing for22information about how to avoid this problem.\23'''24_app_ctx_err_msg = '''\25Working outside of application context.2627This typically means that you attempted to use functionality that needed28to interface with the current application object in a way. To solve29this set up an application context with app.app_context(). See the30documentation for more information.\31'''323334def _lookup_req_object(name):35 top = _request_ctx_stack.top36 if top is None:20 raise RuntimeError('working outside of request context')37 raise RuntimeError(_request_ctx_err_msg)38 return getattr(top, name)394041def _lookup_app_object(name):42 top = _app_ctx_stack.top43 if top is None:27 raise RuntimeError('working outside of application context')44 raise RuntimeError(_app_ctx_err_msg)45 return getattr(top, name)464748def _find_app():49 top = _app_ctx_stack.top50 if top is None:34 raise RuntimeError('working outside of application context')51 raise RuntimeError(_app_ctx_err_msg)52 return top.app535455# context locals
6 unmodified lines