Edgewall Software

Ticket #3655: irequestfilter_patch_3689.diff

File irequestfilter_patch_3689.diff, 1.9 KB (added by simon-code@…, 2 years ago)

Patch for trac.web.main and trac.web.api that adds a 'prepare_request()' method to the IRequestFilter interface.

  • trunk/trac/web/api.py

     
    467467    requests, before and/or after they are processed by the main handler.""" 
    468468 
    469469    def pre_process_request(req, handler): 
    470         """Do any pre-processing the request might need; typically adding 
    471         values to req.hdf, or redirecting. 
     470        """Called after initial handler selection, and can be used to change 
     471        the selected handler or redirect request. 
    472472         
    473473        Always returns the request handler, even if unchanged. 
    474474        """ 
    475475 
     476    def prepare_request(req, handler): 
     477        """Do any pre-processing before actual processing; typically adding 
     478        values to req.hdf, req.environ or similar. 
     479         
     480        If no handler is found or the handler does not use templates, 
     481        req.hdf will be None. 
     482         
     483        Always returns the request object, even if unchanged. 
     484        """ 
     485 
    476486    def post_process_request(req, template, content_type): 
    477487        """Do any post-processing the request might need; typically adding 
    478488        values to req.hdf, or changing template or mime type. 
  • trunk/trac/web/main.py

     
    200200 
    201201        # Prepare HDF for the clearsilver template 
    202202        try: 
     203            req.hdf = None 
    203204            use_template = getattr(chosen_handler, 'use_template', True) 
    204205            if use_template: 
    205206                chrome = Chrome(self.env) 
     
    211212            if not early_error: 
    212213                raise 
    213214 
     215        for f in self.filters: 
     216            req = f.prepare_request(req, chosen_handler) 
     217 
    214218        if early_error: 
    215219            raise early_error[0], early_error[1], early_error[2] 
    216220