Graham Dumpleton
grahamd at dscpl.com.au
Mon Jul 4 18:01:29 EDT 2005
Enable mod_python handler inside the context of a "Directory" directive and not at global scope within Apache configuration file. <Directory /home/mmokrejs/public_html/IRES2> AddHandler mod_python .py PythonHandler mod_python.publisher PythonDebug On </Directory> If web_settings is in that actual directory, it should then be found. If web_settings is elsewhere, it will only find it if it is somewhere along the Python module search path. There are various little issues in current versions code based related to defaulting to index() function. Ie., http://issues.apache.org/jira/browse/MODPYTHON-24 http://issues.apache.org/jira/browse/MODPYTHON-23 There may be some strangeness bound up in all that whereby it has other problems where Directory directive isn't used. Graham On 05/07/2005, at 1:02 AM, Martin MOKREJŠ wrote: > I'll make a small testcase if you wish. The code breaks in the latter > case on very > first line of my code where is > > import web_settings > > with ImportError: No module named web_settings > > > In the former error IOError: [Errno 2] No such file or directory: > '/home/mmokrejs/public_html/IRES2/index.py' > it breaks even before executing my code, as python > handler looks for index.py which doesn't even exist. I have to tell > apache that it shouldn't even look for index.py with that configuration > directive. Still don't understand why when I'm accessing > http://aquarius/~mmokrejs/IRES2/IRESite_web.py and not > http://aquarius/~mmokrejs/IRES2/ > > Martin > > > Julien wrote: >> can you paste your code to http://rafb.net/paste/ ? >> On Mon, 2005-07-04 at 16:24 +0200, Martin MOKREJŠ wrote: >>> Hi, >>> when I have in httpd.conf: >>> >>> <IfDefine PYTHON> >>> <IfModule !mod_python.c> >>> LoadModule python_module modules/mod_python.so >>> </IfModule> >>> </IfDefine> >>> >>> <IfModule mod_python.c> >>> >>> AddHandler mod_python .py >>> PythonHandler mod_python.publisher >>> PythonInterpPerDirectory On >>> PythonDebug On >>> >>> >>> and no .htaccess in my public_html directory and access >>> http://aquarius/~mmokrejs/IRES2/IRESite_web.py?page=all, I get: >>> >>> >>> Mod_python error: "PythonHandler mod_python.publisher" >>> >>> Traceback (most recent call last): >>> >>> File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line >>> 299, in HandlerDispatch >>> result = object(req) >>> >>> File "/usr/lib/python2.4/site-packages/mod_python/publisher.py", >>> line 187, in handler >>> module = page_cache[req] >>> >>> File "/usr/lib/python2.4/site-packages/mod_python/cache.py", line >>> 77, in __getitem__ >>> return self._checkitem(name)[2] >>> >>> File "/usr/lib/python2.4/site-packages/mod_python/cache.py", line >>> 118, in _checkitem >>> opened = self.check(key, name, entry) >>> >>> File "/usr/lib/python2.4/site-packages/mod_python/publisher.py", >>> line 67, in check >>> return ModuleCache.check(self, key, req, entry) >>> >>> File "/usr/lib/python2.4/site-packages/mod_python/cache.py", line >>> 249, in check >>> opened = file(key, self.mode) >>> >>> IOError: [Errno 2] No such file or directory: >>> '/home/mmokrejs/public_html/IRES2/index.py' >>> >>> >>> But, when I create .htaccess with: >>> >>> AddHandler mod_python .py >>> PythonHandler mod_python.publisher >>> PythonInterpPerDirectory On >>> PythonDebug On >>> >>> it works. >>> >>> index.py really doesn't exist. I get rid of this stupid error when >>> .htaccess >>> contains only: >>> >>> <IfModule mod_dir.c> >>> DirectoryIndex IRESite_web.py >>> </IfModule> >>> >>> >>> >>> >>> But then it complains about another module on line 1 in the source >>> file: >>> >>> Mod_python error: "PythonHandler mod_python.publisher" >>> >>> Traceback (most recent call last): >>> >>> File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line >>> 299, in HandlerDispatch >>> result = object(req) >>> >>> File "/usr/lib/python2.4/site-packages/mod_python/publisher.py", >>> line 187, in handler >>> module = page_cache[req] >>> >>> File "/usr/lib/python2.4/site-packages/mod_python/cache.py", line >>> 77, in __getitem__ >>> return self._checkitem(name)[2] >>> >>> File "/usr/lib/python2.4/site-packages/mod_python/cache.py", line >>> 119, in _checkitem >>> value = self.build(key, name, opened, entry) >>> >>> File "/usr/lib/python2.4/site-packages/mod_python/publisher.py", >>> line 77, in build >>> return ModuleCache.build(self, key, req, opened, entry) >>> >>> File "/usr/lib/python2.4/site-packages/mod_python/cache.py", line >>> 369, in build >>> exec opened in module.__dict__ >>> >>> File "/home/mmokrejs/public_html/IRES2/IRESite_web.py", line 1, in ? >>> import web_settings >>> >>> ImportError: No module named web_settings >>> >>> >>> >>> >>> >>> The errors changed, however from IOError: [Errno 2] No such file or >>> directory: '/home/mmokrejs/public_html/IRES2/index.py' >>> to >>> ImportError: No module named web_settings >>> >>> >>> Why does it happen? I use at the moment >>> http://cvs.apache.org/snapshots/mod_python/ >>> mod_python_20050704111017.tar.gz >>> under apache-2.0.54. >>> >>> >>> Martin >>> _______________________________________________ >>> Mod_python mailing list >>> Mod_python at modpython.org >>> http://mailman.modpython.org/mailman/listinfo/mod_python >>> > > -- > Martin Mokrejs > Email: > 'bW9rcmVqc21Acmlib3NvbWUubmF0dXIuY3VuaS5jeg==\n'.decode('base64') > GPG key is at http://www.natur.cuni.cz/~mmokrejs > _______________________________________________ > Mod_python mailing list > Mod_python at modpython.org > http://mailman.modpython.org/mailman/listinfo/mod_python
|