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

Changeset 1370

Show
Ignore:
Timestamp:
09/16/06 17:20:42
Author:
fumanchu
Message:

A couple more priorities for tools.

Files:

Legend:

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

    r1369 r1370  
    3434    """ 
    3535     
    36     def __init__(self, point, callable, name=None): 
     36    def __init__(self, point, callable, name=None, priority=50): 
    3737        self._point = point 
    3838        self.callable = callable 
    3939        self._name = name 
     40        self._priority = priority 
    4041        self.__doc__ = self.callable.__doc__ 
    4142        self._setargs() 
     
    132133        """ 
    133134        f = getattr(self.callable, "failsafe", False) 
    134         p = getattr(self.callable, "priority", 50
     135        p = getattr(self.callable, "priority", self._priority
    135136        cherrypy.request.hooks.attach(self._point, self._wrapper, failsafe=f, 
    136137                                      priority=p, **self._merged_args()) 
     
    291292 
    292293 
    293 default_toolbox = Toolbox() 
     294default_toolbox = _d = Toolbox() 
    294295default_toolbox.session_auth = SessionAuthTool(cptools.session_auth) 
    295 default_toolbox.proxy = Tool('before_request_body', cptools.proxy) 
    296 default_toolbox.response_headers = Tool('on_start_resource', cptools.response_headers) 
     296_d.proxy = Tool('before_request_body', 
     297                             cptools.proxy, priority=30) 
     298_d.response_headers = Tool('on_start_resource', cptools.response_headers) 
    297299# We can't call virtual_host in on_start_resource, 
    298300# because it's failsafe and the redirect would be swallowed. 
    299 default_toolbox.virtual_host = Tool('before_request_body', cptools.virtual_host) 
    300 default_toolbox.log_tracebacks = Tool('before_error_response', cptools.log_traceback) 
    301 default_toolbox.log_headers = Tool('before_error_response', cptools.log_request_headers) 
    302 default_toolbox.err_redirect = ErrorTool(cptools.redirect) 
    303 default_toolbox.etags = Tool('before_finalize', cptools.validate_etags) 
    304 default_toolbox.decode = Tool('before_handler', encoding.decode) 
    305 default_toolbox.encode = Tool('before_finalize', encoding.encode) 
    306 default_toolbox.gzip = Tool('before_finalize', encoding.gzip) 
    307 default_toolbox.staticdir = HandlerTool(static.staticdir) 
    308 default_toolbox.staticfile = HandlerTool(static.staticfile) 
     301_d.virtual_host = Tool('before_request_body', 
     302                                    cptools.virtual_host, priority=40) 
     303_d.log_tracebacks = Tool('before_error_response', cptools.log_traceback) 
     304_d.log_headers = Tool('before_error_response', cptools.log_request_headers) 
     305_d.err_redirect = ErrorTool(cptools.redirect) 
     306_d.etags = Tool('before_finalize', cptools.validate_etags) 
     307_d.decode = Tool('before_handler', encoding.decode) 
     308# the order of encoding, gzip, caching is important 
     309_d.encode = Tool('before_finalize', encoding.encode, priority=70) 
     310_d.gzip = Tool('before_finalize', encoding.gzip, priority=80) 
     311_d.staticdir = HandlerTool(static.staticdir) 
     312_d.staticfile = HandlerTool(static.staticfile) 
    309313# _sessions.init must be bound after headers are read 
    310 default_toolbox.sessions = SessionTool('before_request_body', _sessions.init) 
    311 default_toolbox.xmlrpc = XMLRPCTool() 
    312 default_toolbox.wsgiapp = WSGIAppTool(_wsgiapp.run) 
    313 default_toolbox.caching = CachingTool('before_handler', _caching.get, 'caching') 
    314 default_toolbox.expires = Tool('before_finalize', _caching.expires) 
    315 default_toolbox.tidy = Tool('before_finalize', tidy.tidy) 
    316 default_toolbox.nsgmls = Tool('before_finalize', tidy.nsgmls) 
    317 default_toolbox.ignore_headers = Tool('before_request_body', cptools.ignore_headers) 
    318 default_toolbox.referer = Tool('before_request_body', cptools.referer) 
    319 default_toolbox.basicauth = Tool('on_start_resource', auth.basic_auth) 
    320 default_toolbox.digestauth = Tool('on_start_resource', auth.digest_auth) 
    321 default_toolbox.trailing_slash = Tool('before_handler', cptools.trailing_slash) 
    322  
    323 del cptools, encoding, auth, static, tidy 
     314_d.sessions = SessionTool('before_request_body', _sessions.init) 
     315_d.xmlrpc = XMLRPCTool() 
     316_d.wsgiapp = WSGIAppTool(_wsgiapp.run) 
     317_d.caching = CachingTool('before_handler', _caching.get, 'caching') 
     318_d.expires = Tool('before_finalize', _caching.expires) 
     319_d.tidy = Tool('before_finalize', tidy.tidy) 
     320_d.nsgmls = Tool('before_finalize', tidy.nsgmls) 
     321_d.ignore_headers = Tool('before_request_body', cptools.ignore_headers) 
     322_d.referer = Tool('before_request_body', cptools.referer) 
     323_d.basicauth = Tool('on_start_resource', auth.basic_auth) 
     324_d.digestauth = Tool('on_start_resource', auth.digest_auth) 
     325_d.trailing_slash = Tool('before_handler', cptools.trailing_slash) 
     326 
     327del _d, cptools, encoding, auth, static, tidy 
  • trunk/cherrypy/lib/encoding.py

    r1280 r1370  
    217217            return 
    218218    cherrypy.HTTPError(406, "identity, gzip").set_response() 
    219 gzip.priority = 90 
  • trunk/cherrypy/lib/sessions.py

    r1367 r1370  
    365365                yield line 
    366366    cherrypy.response.body = wrap_body(cherrypy.response.body) 
     367save.failsafe = True 
    367368 
    368369def close(): 
     
    372373        # If the session is still locked we release the lock 
    373374        sess.release_lock() 
    374     del cherrypy._serving.session 
    375375close.failsafe = True 
    376376close.priority = 90 

Hosted by WebFaction

Log in as guest/cpguest to create tickets