Changeset 1542
- Timestamp:
- 12/21/06 01:11:10
- Files:
-
- trunk/cherrypy/_cptools.py (modified) (3 diffs)
- trunk/cherrypy/test/test_tools.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cptools.py
r1495 r1542 101 101 method when the tool is "turned on" in config. 102 102 """ 103 p = getattr(self.callable, "priority", self._priority) 103 conf = self._merged_args() 104 p = conf.pop("priority", None) 105 if p is None: 106 p = getattr(self.callable, "priority", self._priority) 104 107 cherrypy.request.hooks.attach(self._point, self.callable, 105 priority=p, ** self._merged_args())108 priority=p, **conf) 106 109 107 110 … … 142 145 method when the tool is "turned on" in config. 143 146 """ 144 p = getattr(self.callable, "priority", self._priority) 147 conf = self._merged_args() 148 p = conf.pop("priority", None) 149 if p is None: 150 p = getattr(self.callable, "priority", self._priority) 145 151 cherrypy.request.hooks.attach(self._point, self._wrapper, 146 priority=p, ** self._merged_args())152 priority=p, **conf) 147 153 148 154 … … 269 275 """Hook caching into cherrypy.request.""" 270 276 conf = self._merged_args() 271 cherrypy.request.hooks.attach('before_handler', self._wrapper, **conf) 277 278 p = conf.pop("priority", None) 279 cherrypy.request.hooks.attach('before_handler', self._wrapper, 280 priority=p, **conf) 272 281 273 282 trunk/cherrypy/test/test_tools.py
r1530 r1542 104 104 105 105 # Multiple decorators; include kwargs just for fun. 106 # XXXNote that encode must run before gzip.107 def decorated_euro(self ):106 # Note that encode must run before gzip. 107 def decorated_euro(self, *vpath): 108 108 yield u"Hello," 109 109 yield u"world" … … 193 193 'tools.gzip.on': True, 194 194 'tools.encode.on': True, 195 }, 196 # Priority specified in config 197 '/decorated_euro/subpath': { 198 'tools.gzip.priority': 10, 195 199 }, 196 200 } … … 289 293 self.getPage("/decorated_euro", headers=[("Accept-Encoding", "gzip")]) 290 294 self.assertInBody(zbuf.getvalue()[:3]) 295 296 # This should break because gzip's priority was lowered in conf. 297 # Of course, we don't want breakage in production apps, 298 # but it proves the priority was changed. 299 self.getPage("/decorated_euro/subpath", 300 headers=[("Accept-Encoding", "gzip")]) 301 self.assertErrorPage(500, pattern='UnicodeEncodeError') 291 302 292 303 def testBareHooks(self):

