aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/app.py
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2014-11-30 12:49:26 -0600
committerChristopher Allan Webber <cwebber@dustycloud.org>2014-12-03 15:40:56 -0600
commitb88ca698dd4dc4eb486b08bdb10be9123ef01e8e (patch)
tree57a60dca04919eea43789119752f8fc70653b593 /mediagoblin/app.py
parent15c86f3a570e76779be20d817a6a00fe7a9fa5bc (diff)
downloadmediagoblin-b88ca698dd4dc4eb486b08bdb10be9123ef01e8e.tar.lz
mediagoblin-b88ca698dd4dc4eb486b08bdb10be9123ef01e8e.tar.xz
mediagoblin-b88ca698dd4dc4eb486b08bdb10be9123ef01e8e.zip
An environment variable to transition towards removing global variables
Diffstat (limited to 'mediagoblin/app.py')
-rw-r--r--mediagoblin/app.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/mediagoblin/app.py b/mediagoblin/app.py
index 8b231163..e5442010 100644
--- a/mediagoblin/app.py
+++ b/mediagoblin/app.py
@@ -42,6 +42,8 @@ from mediagoblin.tools.pluginapi import PluginManager, hook_transform
from mediagoblin.tools.crypto import setup_crypto
from mediagoblin.auth.tools import check_auth_enabled, no_auth_logout
+from mediagoblin.tools.transition import DISABLE_GLOBALS
+
_log = logging.getLogger(__name__)
@@ -150,9 +152,14 @@ class MediaGoblinApp(object):
# certain properties need to be accessed globally eg from
# validators, etc, which might not access to the request
# object.
+ #
+ # Note, we are trying to transition this out;
+ # run with environment variable DISABLE_GLOBALS=true
+ # to work on it
#######################################################
- setup_globals(app=self)
+ if not DISABLE_GLOBALS:
+ setup_globals(app=self)
# Workbench *currently* only used by celery, so this only
# matters in always eager mode :)
@@ -174,12 +181,7 @@ class MediaGoblinApp(object):
# --------------
# Is a context provided?
- if ctx is not None:
- # Do special things if this is a request
- if isinstance(ctx, Request):
- ctx = self._request_only_gen_context(ctx)
-
- else:
+ if ctx is None:
ctx = Context()
# Attach utilities
@@ -192,6 +194,11 @@ class MediaGoblinApp(object):
ctx.db = self.db
ctx.staticdirect = self.staticdirector
+ # Do special things if this is a request
+ # --------------------------------------
+ if isinstance(ctx, Request):
+ ctx = self._request_only_gen_context(ctx)
+
return ctx
def _request_only_gen_context(self, request):