Changeset 1229
- Timestamp:
- 08/08/06 01:35:07
- Files:
-
- trunk/cherrypy/_cperror.py (modified) (2 diffs)
- trunk/cherrypy/_cprequest.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cperror.py
r1224 r1229 129 129 else: 130 130 raise ValueError("The %s status code is unknown." % status) 131 132 def __call__(self): 133 # Allow the exception to be used as a request.handler. 134 raise self 131 135 132 136 … … 183 187 184 188 _be_ie_unfriendly(self.status) 189 190 def __call__(self): 191 # Allow the exception to be used as a request.handler. 192 raise self 185 193 186 194 trunk/cherrypy/_cprequest.py
r1225 r1229 390 390 391 391 392 class PageHandler(object): 393 """Callable which sets response.body.""" 394 395 def __init__(self, callable, *args, **kwargs): 396 self.callable = callable 397 self.args = args 398 self.kwargs = kwargs 399 400 def __call__(self): 401 cherrypy.response.body = self.callable(*self.args, **self.kwargs) 402 403 404 class LateParamPageHandler(PageHandler): 405 406 def __getattribute__(self, name): 407 attr = object.__getattribute__(self, name) 408 if name == "kwargs": 409 if attr: 410 kwargs = cherrypy.request.params.copy() 411 kwargs.update(attr) 412 else: 413 kwargs = cherrypy.request.params 414 return kwargs 415 else: 416 return attr 417 418 392 419 class Dispatcher(object): 393 420 … … 401 428 402 429 if func: 403 def handler(): 404 cherrypy.response.body = func(*vpath, **request.params) 405 request.handler = handler 406 else: 407 def notfound(): 408 raise cherrypy.NotFound() 409 request.handler = notfound 430 request.handler = LateParamPageHandler(func, *vpath) 431 else: 432 request.handler = cherrypy.NotFound() 410 433 411 434 def find_handler(self, path): … … 545 568 func = getattr(resource, "GET", None) 546 569 if func: 547 def handler(): 548 cherrypy.response.body = func(*vpath, **request.params) 549 request.handler = handler 550 return 570 request.handler = LateParamPageHandler(func, *vpath) 551 571 else: 552 def notallowed(): 553 raise cherrypy.HTTPError(405) 554 request.handler = notallowed 555 else: 556 def notfound(): 557 raise cherrypy.NotFound() 558 request.handler = notfound 572 request.handler = cherrypy.HTTPError(405) 573 else: 574 request.handler = cherrypy.NotFound() 559 575 560 576

