Changeset 1074
- Timestamp:
- 04/26/06 00:01:49
- Files:
-
- trunk/cherrypy/_cprequest.py (modified) (7 diffs)
- trunk/cherrypy/test/test_core.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cprequest.py
r1069 r1074 77 77 cherrypy.response.body = [] 78 78 79 _cputil.get_special_attribute("_cp_log_access" , "_cpLogAccess")()79 _cputil.get_special_attribute("_cp_log_access")() 80 80 81 81 return cherrypy.response … … 174 174 path = self.object_path 175 175 _dispatch = cherrypy.config.get("dispatcher") or dispatch 176 handler = _dispatch(path) 177 cherrypy.response.body = handler(*self.virtual_path, **self.params) 176 _dispatch(path) 178 177 179 178 def processHeaders(self): … … 236 235 237 236 def dispatch(path): 238 """Find the appropriate page handler."""237 """Find and run the appropriate page handler.""" 239 238 request = cherrypy.request 240 handler, opath, vpath = find( request.browser_url,path)239 handler, opath, vpath = find(path) 241 240 242 241 # Remove "root" from opath and join it to get found_object_path 243 request.found_object_path = '/' + '/'.join(opath[1:]) 242 # There are no consumers of this info right now, so this block 243 # may disappear soon. 244 if opath and opath[0] == "root": 245 opath.pop(0) 246 request.found_object_path = '/' + '/'.join(opath) 244 247 245 248 # Decode any leftover %2F in the virtual_path atoms. 246 request.virtual_path = [x.replace("%2F", "/") for x in vpath] 247 248 return handler 249 250 def find(browser_url, objectpath): 249 vpath = [x.replace("%2F", "/") for x in vpath] 250 cherrypy.response.body = handler(*vpath, **request.params) 251 252 def find(objectpath): 251 253 objectTrail = _cputil.get_object_trail(objectpath) 252 254 names = [name for name, candidate in objectTrail] … … 272 274 # had a trailing slash (otherwise, do a redirect). 273 275 if not objectpath.endswith('/'): 274 atoms = browser_url.split("?", 1)276 atoms = cherrypy.request.browser_url.split("?", 1) 275 277 newUrl = atoms.pop(0) + '/' 276 278 if atoms: … … 392 394 cherrypy.request.hooks.run('before_error_response') 393 395 394 self.error_response()396 _cputil.get_special_attribute('_cp_on_error')() 395 397 self.finalize() 396 398 … … 413 415 pass 414 416 415 # Failure in self.error_response, error hooks,or finalize.417 # Failure in error hooks or finalize. 416 418 # Bypass them all. 417 419 if cherrypy.config.get('server.show_tracebacks', False): … … 422 424 self.setBareError(body) 423 425 424 def error_response(self):425 # _cp_on_error will probably change self.body.426 # It may also change the headers, etc.427 _cputil.get_special_attribute('_cp_on_error', '_cpOnError')()428 429 426 def setBareError(self, body=None): 430 427 self.status, self.header_list, self.body = _cputil.bareError(body) trunk/cherrypy/test/test_core.py
r1069 r1074 487 487 data = open(log_file, "rb").readlines() 488 488 self.assertEqual(data[0][-41:], ' INFO Traceback (most recent call last):\n') 489 self.assertEqual(data[ 6], ' raise ValueError()\n')489 self.assertEqual(data[-3], ' raise ValueError()\n') 490 490 491 491 # Test that unhandled tracebacks get written to the error log … … 494 494 self.assertInBody("raise ValueError()") 495 495 data = open(log_file, "rb").readlines() 496 self.assertEqual(data[9][-41:], ' INFO Traceback (most recent call last):\n') 497 self.assertEqual(data[15], ' raise ValueError()\n') 498 # Each error should write only one traceback (9 lines each). 499 self.assertEqual(len(data), 18) 496 self.assertEqual(data[-3], ' raise ValueError()\n') 497 # Each error should write only one traceback (11 lines each). 498 self.assertEqual(len(data), 22) 500 499 finally: 501 500 ignore.pop()

