[mod_python] [patch] 2.7.6 null publisher function

Johannes Erdfelt johannes at erdfelt.com
Thu Apr 18 21:30:48 EST 2002


I've been playing around with mod_python lately and I like it so far.
The only thing I didn't like is the requirement for a function to be
passed before publisher will run anything.

I'd kind of a purist when it comes to URL's, so I made this patch. If
there is no function passed, it defaults to "handler".

JE

-------------- next part --------------
--- mod_python/publisher.py.orig	Tue Apr 16 20:31:06 2002
+++ mod_python/publisher.py	Tue Apr 16 20:34:45 2002
@@ -80,17 +80,17 @@
     args = {}
 
     # get the path PATH_INFO (everthing after script)
-    if not _req.subprocess_env.has_key("PATH_INFO"):
-        raise apache.SERVER_RETURN, apache.HTTP_NOT_FOUND
-    
-    func_path = _req.subprocess_env["PATH_INFO"][1:] # skip fist /
-    func_path = string.replace(func_path, "/", ".")
-    if func_path[-1] == ".":
-        func_path = func_path[:-1] 
+    if _req.subprocess_env.has_key("PATH_INFO"):
+        func_path = _req.subprocess_env["PATH_INFO"][1:] # skip fist /
+        func_path = string.replace(func_path, "/", ".")
+        if func_path[-1] == ".":
+            func_path = func_path[:-1] 
 
-    # if any part of the path begins with "_", abort
-    if func_path[0] == '_' or string.count(func_path, "._"):
-        raise apache.SERVER_RETURN, apache.HTTP_NOT_FOUND
+        # if any part of the path begins with "_", abort
+        if func_path[0] == '_' or string.count(func_path, "._"):
+            raise apache.SERVER_RETURN, apache.HTTP_NOT_FOUND
+    else:
+        func_path = "handler"
 
     # process input, if any
     fs = util.FieldStorage(req, keep_blank_values=1)


More information about the Mod_python mailing list