Index: trunk/trac/web/api.py
===================================================================
--- trunk/trac/web/api.py	(revision 3689)
+++ trunk/trac/web/api.py	(working copy)
@@ -467,12 +467,22 @@
     requests, before and/or after they are processed by the main handler."""
 
     def pre_process_request(req, handler):
-        """Do any pre-processing the request might need; typically adding
-        values to req.hdf, or redirecting.
+        """Called after initial handler selection, and can be used to change
+        the selected handler or redirect request.
         
         Always returns the request handler, even if unchanged.
         """
 
+    def prepare_request(req, handler):
+        """Do any pre-processing before actual processing; typically adding
+        values to req.hdf, req.environ or similar.
+        
+        If no handler is found or the handler does not use templates,
+        req.hdf will be None.
+        
+        Always returns the request object, even if unchanged.
+        """
+
     def post_process_request(req, template, content_type):
         """Do any post-processing the request might need; typically adding
         values to req.hdf, or changing template or mime type.
Index: trunk/trac/web/main.py
===================================================================
--- trunk/trac/web/main.py	(revision 3689)
+++ trunk/trac/web/main.py	(working copy)
@@ -200,6 +200,7 @@
 
         # Prepare HDF for the clearsilver template
         try:
+            req.hdf = None
             use_template = getattr(chosen_handler, 'use_template', True)
             if use_template:
                 chrome = Chrome(self.env)
@@ -211,6 +212,9 @@
             if not early_error:
                 raise
 
+        for f in self.filters:
+            req = f.prepare_request(req, chosen_handler)
+
         if early_error:
             raise early_error[0], early_error[1], early_error[2]
 

