Skip to content

Commit

Permalink
[#3194] Support both Flask and Pylons redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Aug 22, 2016
1 parent ed74749 commit 5349011
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ckan/lib/helpers.py
Expand Up @@ -26,8 +26,9 @@
from markdown import markdown
from bleach import clean as clean_html
from pylons import url as _pylons_default_url
from ckan.common import config
from routes import redirect_to as _redirect_to
from ckan.common import config, is_flask_request
from flask import redirect as _flask_redirect
from routes import redirect_to as _routes_redirect_to
from routes import url_for as _routes_default_url_for
import i18n

Expand Down Expand Up @@ -150,7 +151,10 @@ def redirect_to(*args, **kw):
if _url.startswith('/'):
_url = str(config['ckan.site_url'].rstrip('/') + _url)

return _redirect_to(_url)
if is_flask_request():
return _flask_redirect(_url)
else:
return _routes_redirect_to(_url)


@maintain.deprecated('h.url is deprecated please use h.url_for')
Expand Down

0 comments on commit 5349011

Please sign in to comment.