[mod_python] Errors with Apache 1.3.12 and mod_python

Gregory Trubetskoy grisha at modpython.org
Mon Jul 24 09:56:01 EST 2000


When you run httpd with the -X option from the directory where test.py
lives, it works because by default has the current directory in the python
path.

When you run httpd as a daemon, then your current directory is undefined
(most likely it is ServerRoot). 

To get around this, mod_python prepends the directory for which the
directive is specified to the pythopath. But because you put your
directives in httpd.conf outside of any <Directory> directives, mod_python
does not modify your python path in any way, because it doesn't know how
to. What you should do, if you're not using .htaccess, is:

<Directory /dir/where/test.py/is>
	AddHandler python-program .py
	PythonHandler test
	PythonDebug On
</Directory>

Then "/dir/where/test.py/is" will be added to the python path and it will
work fine.

--
  Gregory (Grisha) Trubetskoy
       grisha at modpython.org

On Mon, 24 Jul 2000, Michael Schwager wrote:

> Hi,
> Yes- I am a newbie.  I just installed apache 1.3.12 with mod_python 2.4.1 
> on my Solaris 2.6 box.  Everything went ok, except I am getting an error 
> when I try to run the test.py as instructed in the install docs (see 
> below).  Notice that, strangely, I get no errors- indeed the script works 
> fine- if I run httpd with the -X option.  I note that I must be in the 
> htdocs directory for that to work (thus, httpd sees the test subdir, which 
> contains the test.py file).  So I'm not sure how the directories and 
> filenames are related to PythonHandler, and how they are found by httpd 
> and/or python.  But I think the problem is path-related.
> 
> Any useful help will be appreciated.  I do not have a .htaccess file; I put 
> the appropriate lines in the httpd.conf file:
> AddHandler python-program .py
> PythonHandler test
> PythonDebug On
> 
> Here is the error:
> [Mon Jul 24 02:17:20 2000] [error] PythonHandler test: Traceback (most 
> recent call last):
> [Mon Jul 24 02:17:20 2000] [error] PythonHandler test:   File 
> "/usr/local/lib/python1.6/site-packages/mod_python/apache.py", line 116, in 
> Dispatch
>     object = self.resolve_object(module, object_str)
> [Mon Jul 24 02:17:20 2000] [error] PythonHandler test:   File 
> "/usr/local/lib/python1.6/site-packages/mod_python/apache.py", line 51, in 
> resolve_object
>     raise AttributeError, s
> [Mon Jul 24 02:17:20 2000] [error] PythonHandler test: AttributeError: 
> module '/usr/local/lib/python1.6/test/__init__.pyc' contains no 'handler'
> --
> -Mike                                Mike at Schwager.com
>         
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://www.modpython.org/mailman/listinfo/mod_python
> 




More information about the Mod_python mailing list