From eab36be298ddb1ae39347468fbe13bad9c3b086b Mon Sep 17 00:00:00 2001 From: amercader Date: Thu, 11 Aug 2016 15:03:45 +0100 Subject: [PATCH] [#3196] Replace Pylons' g and c with a proxy To either Flask's `g` or Pylons `c` depending on who serves the request. Pylons' `g` is no longer used. --- ckan/common.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ckan/common.py b/ckan/common.py index d11c4350d4f..afe2edf23e3 100644 --- a/ckan/common.py +++ b/ckan/common.py @@ -16,7 +16,7 @@ from werkzeug.local import Local, LocalProxy from pylons.i18n import _, ungettext -from pylons import g, c, session, response +from pylons import session, response import simplejson as json try: @@ -139,6 +139,13 @@ def params(self): return self.args +def _get_c(): + if is_flask_request(): + return flask.g + else: + return pylons.c + + local = Local() # This a proxy to the bounded config object @@ -149,3 +156,5 @@ def params(self): # Proxies to already thread-local safe objects request = CKANRequest(_get_request) +# Provide a `c` alias for `g` for backwards compatibility +g = c = LocalProxy(_get_c)