Robert Brewer avatar Robert Brewer committed ee2b444

Fix for #372 (browserUrl and querystrings).

Comments (0)

Files changed (1)


     def __init__(self, path, params=None):
         import cherrypy
-        import cgi
+        import cgi
+        request = cherrypy.request
         # Set a 'path' member attribute so that code which traps this
         # error can have access to it.
         if params is not None:
             if isinstance(params, basestring):
-                cherrypy.request.queryString = params
+                request.queryString = params
                 pm = cgi.parse_qs(params, keep_blank_values=True)
                 for key, val in pm.items():
                     if len(val) == 1:
                         pm[key] = val[0]
-                cherrypy.request.paramMap = pm
+                request.paramMap = pm
-                cherrypy.request.queryString = urllib.urlencode(params)
-                cherrypy.request.paramMap = params.copy()
+                request.queryString = urllib.urlencode(params)
+                request.paramMap = params.copy()
-        cherrypy.request.browserUrl = cherrypy.request.base + path
+        request.browserUrl = request.base + path
+        if request.queryString:
+            request.browserUrl += '?' + request.queryString
             # Note that urljoin will "do the right thing" whether url is:
             #  1. a complete URL with host (e.g. "")
             #  2. a URL relative to root (e.g. "/dummy")
-            #  3. a URL relative to the current path
+            #  3. a URL relative to the current path
+            # Note that any querystring in browserUrl will be discarded.
             url = urlparse.urljoin(cherrypy.request.browserUrl, url)
         self.urls = abs_urls
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.