Skip to content

Commit

Permalink
[#3196] Replace Pylons' g and c with a proxy
Browse files Browse the repository at this point in the history
To either Flask's `g` or Pylons `c` depending on who serves the request.

Pylons' `g` is no longer used.
  • Loading branch information
amercader committed Aug 11, 2016
1 parent c087a72 commit eab36be
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ckan/common.py
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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)

0 comments on commit eab36be

Please sign in to comment.