Ticket #3328: trap_early_errors-r3491.diff
| File trap_early_errors-r3491.diff, 3.0 KB (added by cboos, 2 years ago) |
|---|
-
trac/web/main.py
160 160 161 161 # Select the component that should handle the request 162 162 chosen_handler = None 163 if not req.path_info or req.path_info == '/': 164 chosen_handler = self.default_handler 165 else: 166 for handler in self.handlers: 167 if handler.match_request(req): 168 chosen_handler = handler 169 break 163 early_error = None 164 try: 165 if not req.path_info or req.path_info == '/': 166 chosen_handler = self.default_handler 167 else: 168 for handler in self.handlers: 169 if handler.match_request(req): 170 chosen_handler = handler 171 break 170 172 171 for filter_ in self.filters: 172 chosen_handler = filter_.pre_process_request(req, chosen_handler) 173 for filter_ in self.filters: 174 chosen_handler = filter_.pre_process_request(req, 175 chosen_handler) 176 except Exception, e: 177 early_error = (e, sys.exc_traceback) 178 179 if not chosen_handler and not early_error: 180 early_error = (HTTPNotFound('No handler matched request to %s', 181 req.path_info), None) 173 182 174 if not chosen_handler:175 raise HTTPNotFound('No handler matched request to %s',176 req.path_info)177 178 183 # Attach user information to the request 179 anonymous_request = getattr(chosen_handler, 'anonymous_request', False) 180 if anonymous_request: 181 req.authname = 'anonymous' 182 req.perm = NoPermissionCache() 183 else: 184 req.authname = self.authenticate(req) 185 req.perm = PermissionCache(self.env, req.authname) 186 req.session = Session(self.env, req) 184 try: 185 anonymous_request = getattr(chosen_handler, 'anonymous_request', 186 False) 187 if anonymous_request: 188 req.authname = 'anonymous' 189 req.perm = NoPermissionCache() 190 else: 191 req.authname = self.authenticate(req) 192 req.perm = PermissionCache(self.env, req.authname) 193 req.session = Session(self.env, req) 194 except Exception, e: 195 early_error = (e, sys.exc_traceback) 187 196 188 197 # Prepare HDF for the clearsilver template 189 198 use_template = getattr(chosen_handler, 'use_template', True) … … 193 202 populate_hdf(req.hdf, self.env, req) 194 203 chrome.populate_hdf(req, chosen_handler) 195 204 205 if early_error: 206 raise early_error[0], None, early_error[1] 207 196 208 # Process the request and render the template 197 209 try: 198 210 try:
