Skip to content

Commit

Permalink
[xs] keep urls clean
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Mar 1, 2012
1 parent f2de60e commit 05d8800
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ckan/lib/helpers.py
Expand Up @@ -50,9 +50,12 @@ def url(*args, **kw):
return _add_i18n_to_url(my_url, locale=locale, **kw)

def url_for(*args, **kw):

"""Create url adding i18n information if selected
wrapper for routes.url_for"""
locale = kw.pop('locale', None)
# remove __ckan_no_root and add after to not pollute url
no_root = kw.pop('__ckan_no_root', False)
# routes will get the wrong url for APIs if the ver is not provided
if kw.get('controller') == 'api':
ver = kw.get('ver')
Expand All @@ -61,6 +64,7 @@ def url_for(*args, **kw):
# fix ver to include the slash
kw['ver'] = '/%s' % ver
my_url = _routes_default_url_for(*args, **kw)
kw['__ckan_no_root'] = no_root
return _add_i18n_to_url(my_url, locale=locale, **kw)

def url_for_static(*args, **kw):
Expand Down

0 comments on commit 05d8800

Please sign in to comment.