Changeset 1147
- Timestamp:
- 06/19/06 00:07:40
- Files:
-
- trunk/cherrypy/_cprequest.py (modified) (1 diff)
- trunk/cherrypy/test/test_tools.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cprequest.py
r1146 r1147 337 337 bucket = self.toolmap.setdefault(toolname, {}) 338 338 bucket[".".join(atoms)] = v 339 elif namespace == "hooks": 340 # Attach bare hooks declared in config. 341 hookpoint = atoms[0] 342 if isinstance(v, basestring): 343 v = cherrypy.lib.attributes(v) 344 self.hooks.attach(hookpoint, v) 339 345 340 346 # Run tool._setup(conf) for each tool in the new toolmap. trunk/cherrypy/test/test_tools.py
r1145 r1147 64 64 tools.nadsat = NadsatTool() 65 65 66 def pipe_body(): 67 cherrypy.request.process_request_body = False 68 clen = int(cherrypy.request.headers['Content-Length']) 69 cherrypy.request.body = cherrypy.request.rfile.read(clen) 70 66 71 class Root: 67 72 def index(self): … … 74 79 yield europoundUnicode 75 80 euro.exposed = True 81 82 # Bare hooks 83 def pipe(self): 84 return cherrypy.request.body 85 pipe.exposed = True 86 pipe._cp_config = {'hooks.before_request_body': pipe_body} 76 87 77 88 root = Root() … … 93 104 94 105 # METHOD ONE: 95 # Use_cp_config106 # Declare Tools in _cp_config 96 107 class Demo(Test): 97 108 … … 129 140 conf = { 130 141 # METHOD THREE: 131 # D o it allin detached config142 # Declare Tools in detached config 132 143 '/demo': { 133 144 'tools.numerify.on': True, … … 211 222 self.getPage("/euro", headers=[("Accept-Encoding", "gzip")]) 212 223 self.assertInBody(zbuf.getvalue()[:3]) 224 225 def testBareHooks(self): 226 content = "bit of a pain in me gulliver" 227 self.getPage("/pipe", 228 headers=[("Content-Length", len(content)), 229 ("Content-Type", "text/plain")], 230 method="POST", body=content) 231 self.assertBody(content) 213 232 214 233

