Unless I am missing something, the fix is quite trivial as it specially
affects just the case where "index.py" is explicitly added to
req.filename
within the publisher code.
Index: lib/python/mod_python/publisher.py
===================================================================
--- lib/python/mod_python/publisher.py (revision 240397)
+++ lib/python/mod_python/publisher.py (working copy)
@@ -166,6 +166,9 @@
# we'll just insert the module name index.py in the middle
path, func_path = split(req.filename)
req.filename = join(path, 'index.py')
+
+ if not exists(req.filename):
+ raise apache.SERVER_RETURN, apache.HTTP_NOT_FOUND
# I don't know if it's still possible to have a path_info
# but if we have one, we append it to the filename which
On 27/08/2005, at 12:37 AM, Jim Gallacher wrote:
I was hoping there would be a simple fix for this but a quick glance
at the code makes me think that will not be the case. Also, I don't
think this is a new bug as 3.1.4 does not generate a 404 NOT FOUND
response either:
Mod_python error: "PythonHandler mod_python.publisher"
Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line
299, in HandlerDispatch
result = object(req)
File "/usr/lib/python2.3/site-packages/mod_python/publisher.py",
line 98, in handler
path=[path])
File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line
454, in import_module
f, p, d = imp.find_module(parts[i], path)
ImportError: No module named index
We should create a new JIRA issue. If it turns out that the fix is not
easy, is this a big enough problem to hold up the 3.2 release?
Regards,
Jim
Graham Dumpleton wrote:
In 3.2 beta, if one uses:
SetHandler mod_python
PythonHandler mod_python.publisher
PythonDebug On
and you DO NOT have an index.py file and use a URL where the first
URL component doesn't map explicitly to a .py file, you will get
a Python error rather than a 404 NOT FOUND response. For example,
for URL "http://localhost:8080/~grahamd/mp32/index", I get:
Mod_python error: "PythonHandler mod_python.publisher"
Traceback (most recent call last):
File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/site-packages/mod_python/apache.py", line 299, in
HandlerDispatch
result = object(req)
File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/site-packages/mod_python/publisher.py", line 192, in
handler
module = page_cache[req]
File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/site-packages/mod_python/cache.py", line 77, in __getitem__
return self._checkitem(name)[2]
File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/site-packages/mod_python/cache.py", line 118, in _checkitem
opened = self.check(key, name, entry)
File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/site-packages/mod_python/publisher.py", line 67, in check
return ModuleCache.check(self, key, req, entry)
File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/site-packages/mod_python/cache.py", line 249, in check
opened = file(key, self.mode)
IOError: [Errno 2] No such file or directory:
'/Users/grahamd/Sites/mp32/index.py'