Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/websdk/flask/globals.py
diff options
context:
space:
mode:
authorSebastian Silva <sebastian@sugarlabs.org>2011-09-28 00:19:33 (GMT)
committer Sebastian Silva <sebastian@sugarlabs.org>2011-09-28 06:54:34 (GMT)
commit5861585e94a32b3032ac473804bf90c6e1363940 (patch)
treefb3a5bab0d75bf8eb780e749737fea87369754db /websdk/flask/globals.py
parentbe7aa93d7ba3682d5189e1a7d72169c0b02a1ec1 (diff)
Migrated to Flask, added JQuery sugar theme, fixed race condition
Diffstat (limited to 'websdk/flask/globals.py')
-rw-r--r--websdk/flask/globals.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/websdk/flask/globals.py b/websdk/flask/globals.py
new file mode 100644
index 0000000..16580d1
--- /dev/null
+++ b/websdk/flask/globals.py
@@ -0,0 +1,28 @@
+# -*- coding: utf-8 -*-
+"""
+ flask.globals
+ ~~~~~~~~~~~~~
+
+ Defines all the global objects that are proxies to the current
+ active context.
+
+ :copyright: (c) 2011 by Armin Ronacher.
+ :license: BSD, see LICENSE for more details.
+"""
+
+from functools import partial
+from werkzeug.local 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'))