Changeset 1372
- Timestamp:
- 09/22/06 20:25:15
- Files:
-
- trunk/cherrypy/_cptools.py (modified) (2 diffs)
- trunk/cherrypy/lib/encoding.py (modified) (1 diff)
- trunk/cherrypy/test/test_tools.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cptools.py
r1370 r1372 92 92 method when the tool is "turned on" in config. 93 93 """ 94 conf = self._merged_args() 95 cherrypy.request.hooks.attach(self._point, self.callable, **conf) 94 f = getattr(self.callable, "failsafe", False) 95 p = getattr(self.callable, "priority", self._priority) 96 cherrypy.request.hooks.attach(self._point, self.callable, failsafe=f, 97 priority=p, **self._merged_args()) 96 98 97 99 … … 294 296 default_toolbox = _d = Toolbox() 295 297 default_toolbox.session_auth = SessionAuthTool(cptools.session_auth) 296 _d.proxy = Tool('before_request_body', 297 cptools.proxy, priority=30) 298 _d.proxy = Tool('before_request_body', cptools.proxy, priority=30) 298 299 _d.response_headers = Tool('on_start_resource', cptools.response_headers) 299 300 # We can't call virtual_host in on_start_resource, 300 301 # because it's failsafe and the redirect would be swallowed. 301 _d.virtual_host = Tool('before_request_body', 302 cptools.virtual_host, priority=40) 302 _d.virtual_host = Tool('before_request_body', cptools.virtual_host, priority=40) 303 303 _d.log_tracebacks = Tool('before_error_response', cptools.log_traceback) 304 304 _d.log_headers = Tool('before_error_response', cptools.log_request_headers) trunk/cherrypy/lib/encoding.py
r1370 r1372 104 104 raise cherrypy.HTTPError(500, failmsg % encoding) 105 105 106 # Parse the Accept _Charset request header, and try to provide one106 # Parse the Accept-Charset request header, and try to provide one 107 107 # of the requested charsets (in order of user preference). 108 108 encs = cherrypy.request.headers.elements('Accept-Charset') trunk/cherrypy/test/test_tools.py
r1311 r1372 84 84 85 85 def euro(self): 86 hooks = list(cherrypy.request.hooks['before_finalize']) 87 hooks.sort() 88 assert [x.callback.__name__ for x in hooks] == ['encode', 'gzip'] 89 assert [x.priority for x in hooks] == [70, 80] 86 90 yield u"Hello," 87 91 yield u"world" … … 234 238 zfile.close() 235 239 236 self.getPage("/euro", headers=[("Accept-Encoding", "gzip")]) 240 self.getPage("/euro", headers=[("Accept-Encoding", "gzip"), 241 ("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7")]) 237 242 self.assertInBody(zbuf.getvalue()[:3]) 238 243

