diff options
author | florent <florent.pigout@gmail.com> | 2011-09-11 13:42:44 (GMT) |
---|---|---|
committer | florent <florent.pigout@gmail.com> | 2011-09-11 13:42:44 (GMT) |
commit | 131ab16ed7ce9289de5e51bcc1bc23a118a27dd4 (patch) | |
tree | 03384ee657090e627f4b8763c36f0f3787524583 /creactiweb/_templates/lib/flask/globals.py | |
parent | 3e4ef40085c12d53690668e4504a0f70393f6cfa (diff) |
add project template for flask besed activity
Diffstat (limited to 'creactiweb/_templates/lib/flask/globals.py')
-rw-r--r-- | creactiweb/_templates/lib/flask/globals.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/creactiweb/_templates/lib/flask/globals.py b/creactiweb/_templates/lib/flask/globals.py new file mode 100644 index 0000000..8471410 --- /dev/null +++ b/creactiweb/_templates/lib/flask/globals.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +""" + flask.globals + ~~~~~~~~~~~~~ + + Defines all the global objects that are proxies to the current + active context. + + :copyright: (c) 2010 by Armin Ronacher. + :license: BSD, see LICENSE for more details. +""" + +from functools import partial +from werkzeug import LocalStack, LocalProxy + +def _lookup_object(name): + top = _request_ctx_stack.top + if top is None: + raise RuntimeError('working outside of request context') + return getattr(top, name) + +# context locals +_request_ctx_stack = LocalStack() +current_app = LocalProxy(partial(_lookup_object, 'app')) +request = LocalProxy(partial(_lookup_object, 'request')) +session = LocalProxy(partial(_lookup_object, 'session')) +g = LocalProxy(partial(_lookup_object, 'g')) |