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

Ticket #548: before_handler.patch

  • test/test_core.py

    old new  
    136136    def login_redir(): 
    137137        if not getattr(cherrypy.request, "login", None): 
    138138            raise cherrypy.InternalRedirect("/internalredirect/login") 
    139     tools.login_redir = _cptools.Tool('before_main', login_redir) 
     139    tools.login_redir = _cptools.Tool('before_handler', login_redir) 
    140140     
    141141    class InternalRedirect(Test): 
    142142         
  • _cprequest.py

    old new  
    8787    config = None 
    8888    error_response = cherrypy.HTTPError(500).set_response 
    8989    hookpoints = ['on_start_resource', 'before_request_body', 
    90                   'before_main', 'before_finalize', 
     90                  'before_handler', 'before_finalize', 
    9191                  'on_end_resource', 'on_end_request', 
    9292                  'before_error_response', 'after_error_response'] 
    9393    hooks = HookMap(hookpoints) 
     
    236236                if self.process_request_body: 
    237237                    self.process_body() 
    238238                 
    239                 self.hooks.run('before_main') 
     239                self.hooks.run('before_handler') 
    240240                if self.handler: 
    241241                    self.handler() 
    242242                self.hooks.run('before_finalize') 
  • lib/caching.py

    old new  
    164164    conf = cherrypy.request.toolmap.get("caching", {}) 
    165165    if not getattr(cherrypy, "_cache", None): 
    166166        init(conf.get("class", None)) 
    167     cherrypy.request.hooks.attach('before_main', _wrapper) 
     167    cherrypy.request.hooks.attach('before_handler', _wrapper) 
    168168 
    169169def expires(secs=0, force=False): 
    170170    """Tool for influencing cache mechanisms using the 'Expires' header. 
  • _cptools.py

    old new  
    9595        cherrypy.request.hooks.attach(self._point, self.callable, conf) 
    9696 
    9797 
    98 class MainTool(Tool): 
    99     """Tool which is called 'before main', that may skip normal handlers. 
     98class HandlerTool(Tool): 
     99    """Tool which is called 'before handler', that may skip normal handlers. 
    100100     
    101101    The callable provided should return True if processing should skip 
    102102    the normal page handler, and False if it should not. 
    103103    """ 
    104104     
    105105    def __init__(self, callable, name=None): 
    106         Tool.__init__(self, 'before_main', callable, name) 
     106        Tool.__init__(self, 'before_handler', callable, name) 
    107107     
    108108    def handler(self, *args, **kwargs): 
    109109        """Use this tool as a CherryPy page handler. 
     
    226226            raise cherrypy.InternalRedirect(ppath) 
    227227 
    228228 
    229 class WSGIAppTool(MainTool): 
     229class WSGIAppTool(HandlerTool): 
    230230    """A tool for running any WSGI middleware/application within CP. 
    231231     
    232232    Here are the parameters: 
     
    247247    def _setup(self): 
    248248        # Keep request body intact so the wsgi app can have its way with it. 
    249249        cherrypy.request.process_request_body = False 
    250         MainTool._setup(self) 
     250        HandlerTool._setup(self) 
    251251 
    252252 
    253253class CachingTool: 
     
    270270 
    271271 
    272272default_toolbox = Toolbox() 
    273 default_toolbox.session_auth = MainTool(cptools.session_auth) 
     273default_toolbox.session_auth = HandlerTool(cptools.session_auth) 
    274274default_toolbox.proxy = Tool('before_request_body', cptools.proxy) 
    275275default_toolbox.response_headers = Tool('on_start_resource', cptools.response_headers) 
    276276# We can't call virtual_host in on_start_resource, 
     
    280280default_toolbox.log_headers = Tool('before_error_response', cptools.log_request_headers) 
    281281default_toolbox.err_redirect = ErrorTool(cptools.redirect) 
    282282default_toolbox.etags = Tool('before_finalize', cptools.validate_etags) 
    283 default_toolbox.decode = Tool('before_main', encoding.decode) 
     283default_toolbox.decode = Tool('before_handler', encoding.decode) 
    284284default_toolbox.encode = Tool('before_finalize', encoding.encode) 
    285285default_toolbox.gzip = Tool('before_finalize', encoding.gzip) 
    286 default_toolbox.staticdir = MainTool(static.staticdir) 
    287 default_toolbox.staticfile = MainTool(static.staticfile) 
     286default_toolbox.staticdir = HandlerTool(static.staticdir) 
     287default_toolbox.staticfile = HandlerTool(static.staticfile) 
    288288# _sessions.init must be bound after headers are read 
    289289default_toolbox.sessions = SessionTool('before_request_body', _sessions.init) 
    290290default_toolbox.xmlrpc = XMLRPCTool() 

Hosted by WebFaction

Log in as guest/cpguest to create tickets