Changeset 1130
- Timestamp:
- 06/09/06 03:00:45
- Files:
-
- trunk/cherrypy/_cperror.py (modified) (3 diffs)
- trunk/cherrypy/_cprequest.py (modified) (1 diff)
- trunk/cherrypy/test/test_core.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cperror.py
r1128 r1130 4 4 import sys 5 5 import traceback 6 import urllib7 6 import urlparse 8 7 … … 20 19 """Exception raised when processing should be handled by a different path. 21 20 22 If you supply 'params', it will be used to re-populate params. 23 If 'params' is a dict, it will be used directly. 24 If 'params' is a string, it will be converted to a dict using cgi.parse_qs. 25 26 If you omit 'params', the params from the original request will 27 remain in effect, including any POST parameters. 28 """ 29 30 def __init__(self, path, params=None): 21 If you supply a query string, it will be replace request.params. 22 If you omit the query string, the params from the original request will 23 remain in effect. 24 """ 25 26 def __init__(self, path): 31 27 import cherrypy 32 28 request = cherrypy.request 29 30 if "?" in path: 31 # Pop any params included in the path 32 path, pm = path.split("?", 1) 33 request.query_string = pm 34 request.params = httptools.parseQueryString(pm) 33 35 34 36 # Note that urljoin will "do the right thing" whether url is: … … 42 44 self.path = path 43 45 44 if params is not None: 45 if isinstance(params, basestring): 46 request.query_string = params 47 pm = cgi.parse_qs(params, keep_blank_values=True) 48 for key, val in pm.items(): 49 if len(val) == 1: 50 pm[key] = val[0] 51 request.params = pm 52 else: 53 request.query_string = urllib.urlencode(params) 54 request.params = params.copy() 55 56 Exception.__init__(self, path, params) 46 Exception.__init__(self, path) 57 47 58 48 trunk/cherrypy/_cprequest.py
r1118 r1130 92 92 When run() is done, the returned object should have 3 attributes: 93 93 status, e.g. "200 OK" 94 header s, a list of (name, value) tuples94 header_list, a list of (name, value) tuples 95 95 body, an iterable yielding strings 96 96 trunk/cherrypy/test/test_core.py
r1128 r1130 154 154 if user_id == "parrot": 155 155 # Trade it for a slug when redirecting 156 raise cherrypy.InternalRedirect('/image/getImagesByUser', 157 "user_id=slug") 156 raise cherrypy.InternalRedirect('/image/getImagesByUser?user_id=slug') 158 157 elif user_id == "terrier": 159 158 # Trade it for a fish when redirecting 160 raise cherrypy.InternalRedirect('/image/getImagesByUser',161 {"user_id": "fish"})159 cherrypy.request.params = {"user_id": "fish"} 160 raise cherrypy.InternalRedirect('/image/getImagesByUser') 162 161 else: 163 162 raise cherrypy.InternalRedirect('/image/getImagesByUser')

