Skip to content

Commit

Permalink
Merge branch 'poc-flask-views.common-url_for-take-2' into poc-flask-v…
Browse files Browse the repository at this point in the history
…iews.common-url_for-take-2-tests
  • Loading branch information
amercader committed Jun 8, 2016
2 parents 77e0cfa + 8f0db26 commit c00b457
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
10 changes: 10 additions & 0 deletions ckan/common.py
Expand Up @@ -44,6 +44,16 @@ class Request(object):
Wraps the request object, returning attributes from either the Flask or
Pylons request object, depending of whether flask.request is available.
'''

@property
def params(self):
''' Special case as request.params is used all over the place.
'''
if is_flask():
return flask.request.args
else:
return pylons.request.params

def __getattr__(self, name):
if is_flask():
return getattr(flask.request, name, None)
Expand Down
2 changes: 1 addition & 1 deletion ckan/config/middleware/flask_app.py
Expand Up @@ -86,7 +86,7 @@ def save_session(self, app, session, response):
data_dir=cache_dir),
'session.key': app_conf.get('beaker.session.key'),
'session.cookie_expires':
app_conf.get('beaker.session.cookie_expires'),
app_conf.get('beaker.session.cookie_expires'),
'session.secret': app_conf.get('beaker.session.secret')
}
app.wsgi_app = SessionMiddleware(app.wsgi_app, session_opts)
Expand Down
7 changes: 3 additions & 4 deletions ckan/lib/helpers.py
Expand Up @@ -207,13 +207,12 @@ def url_for(*args, **kw):
if not ver:
raise Exception('api calls must specify the version! e.g. ver=3')

if kw.get('qualified', False) or kw.get('_external', False):
kw['protocol'], kw['host'] = get_site_protocol_and_host()

original_args = tuple(args)
original_kw = kw.copy()

if kw.get('qualified', False) or kw.get('_external', False):
original_kw['protocol'], original_kw['host'] = get_site_protocol_and_host()

# TODO: this probably does not cover all cases
if (len(args) and '_' in args[0]
and '.' not in args[0]
and not args[0].startswith('/')):
Expand Down

0 comments on commit c00b457

Please sign in to comment.