Skip to content

Commit

Permalink
add current url into environ
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Feb 20, 2012
1 parent 1b6eb8a commit 017feb0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ckan/config/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,16 @@ def __call__(self, environ, start_response):
# use default language from config
environ['CKAN_LANG'] = self.default_locale
environ['CKAN_LANG_IS_DEFAULT'] = True

# It's useful to know the current application url
# We only update once for a request so we can keep
# the original url which helps with 404 pages etc
if 'CKAN_CURRENT_URL' not in environ:
path_info = environ['PATH_INFO']
qs = environ['QUERY_STRING']
if qs:
environ['CKAN_CURRENT_URL'] = '%s?%s' % (path_info, qs)
else:
environ['CKAN_CURRENT_URL'] = path_info

return self.app(environ, start_response)

0 comments on commit 017feb0

Please sign in to comment.