Changeset 1621
- Timestamp:
- 02/19/07 14:03:57
- Files:
-
- trunk/cherrypy/_cptools.py (modified) (2 diffs)
- trunk/cherrypy/test/test_tools.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cptools.py
r1608 r1621 50 50 except (ImportError, AttributeError): 51 51 pass 52 except TypeError: 53 if hasattr(self.callable, "__call__"): 54 for arg in inspect.getargspec(self.callable.__call__)[0]: 55 setattr(self, arg, None) 52 56 # IronPython 1.0 raises NotImplementedError because 53 57 # inspect.getargspec tries to access Python bytecode … … 109 113 """Tool which is called 'before main', that may skip normal handlers. 110 114 111 The callable provided should return True if processing should skip 112 the normal page handler, and False if it should not. 115 If the tool successfully handles the request (by setting response.body), 116 if should return True. This will cause CherryPy to skip any 'normal' page 117 handler. If the tool did not handle the request, it should return False 118 to tell CherryPy to continue on and call the normal page handler. If the 119 tool is declared AS a page handler (see the 'handler' method), returning 120 False will raise NotFound. 113 121 """ 114 122 trunk/cherrypy/test/test_tools.py
r1551 r1621 82 82 clen = int(cherrypy.request.headers['Content-Length']) 83 83 cherrypy.request.body = cherrypy.request.rfile.read(clen) 84 85 # Assert that we can use a callable object instead of a function. 86 class Rotator(object): 87 def __call__(self, scale): 88 r = cherrypy.response 89 r.collapse_body() 90 r.body = [chr(ord(x) + scale) for x in r.body] 91 cherrypy.tools.rotator = cherrypy.Tool('before_finalize', Rotator()) 84 92 85 93 class Root:

