Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 1372

Show
Ignore:
Timestamp:
09/22/06 20:25:15
Author:
fumanchu
Message:

Fix to tool priorities.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/_cptools.py

    r1370 r1372  
    9292        method when the tool is "turned on" in config. 
    9393        """ 
    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()) 
    9698 
    9799 
     
    294296default_toolbox = _d = Toolbox() 
    295297default_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) 
    298299_d.response_headers = Tool('on_start_resource', cptools.response_headers) 
    299300# We can't call virtual_host in on_start_resource, 
    300301# 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) 
    303303_d.log_tracebacks = Tool('before_error_response', cptools.log_traceback) 
    304304_d.log_headers = Tool('before_error_response', cptools.log_request_headers) 
  • trunk/cherrypy/lib/encoding.py

    r1370 r1372  
    104104            raise cherrypy.HTTPError(500, failmsg % encoding) 
    105105     
    106     # Parse the Accept_Charset request header, and try to provide one 
     106    # Parse the Accept-Charset request header, and try to provide one 
    107107    # of the requested charsets (in order of user preference). 
    108108    encs = cherrypy.request.headers.elements('Accept-Charset') 
  • trunk/cherrypy/test/test_tools.py

    r1311 r1372  
    8484         
    8585        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] 
    8690            yield u"Hello," 
    8791            yield u"world" 
     
    234238        zfile.close() 
    235239         
    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")]) 
    237242        self.assertInBody(zbuf.getvalue()[:3]) 
    238243         

Hosted by WebFaction

Log in as guest/cpguest to create tickets