forked from orbit-oss/flask
Implemented a separate application context.
This commit is contained in:
parent
a1305973bf
commit
47288231fe
3 changed files with 78 additions and 3 deletions
|
|
@ -20,9 +20,17 @@ def _lookup_object(name):
|
|||
return getattr(top, name)
|
||||
|
||||
|
||||
def _find_app():
|
||||
top = _app_ctx_stack.top
|
||||
if top is None:
|
||||
raise RuntimeError('working outside of application context')
|
||||
return top.app
|
||||
|
||||
|
||||
# context locals
|
||||
_request_ctx_stack = LocalStack()
|
||||
current_app = LocalProxy(partial(_lookup_object, 'app'))
|
||||
_app_ctx_stack = LocalStack()
|
||||
current_app = LocalProxy(_find_app)
|
||||
request = LocalProxy(partial(_lookup_object, 'request'))
|
||||
session = LocalProxy(partial(_lookup_object, 'session'))
|
||||
g = LocalProxy(partial(_lookup_object, 'g'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue