views:

49

answers:

3

I am having issues with getting my Mod Python to work properly.

I have followed mod_python manual found here

So here is my Apache setup (I am using Virtual Hosts):

<VirtualHost *:80>
    ServerName hostname
    DocumentRoot "C:/Documents and Settings/username/hostname/www"

    <Directory "C:/Documents and Settings/username/hostname">
        DirectoryIndex index.py
        AddHandler mod_python .py
        PythonHandler www.index
        PythonDebug On
    </Directory>
</VirtualHost>

Here is my handler index.py:

from mod_python import apache

def handler(req):
    req.content_type = "text\plain"
    req.write("Hello World!")
    return apache.OK

After setting all that up I get the following error:

ImportError: No module named www.index

NOTE: The reason I am adding www to index, is because that is what the mod_python tutorial stated:

Attempt to import a module by name myscript. (Note that if myscript was in a subdirectory of the directory where PythonHandler was specified, then the import would not work because said subdirectory would not be in the sys.path. One way around this is to use package notation, e.g. "PythonHandler subdir.myscript".)

If I use mod_python.publisher as my PythonHandler, everything works fine. Not sure what I am missing here.

+2  A: 

Have you thought of using mod_wsgi http://code.google.com/p/modwsgi/? I personally gave up on mod_python long ago.

Frank Malina
+2  A: 

If you can stop using mod_python as it is abandoned now. mod_wsgi is the way to go.

marcelor
you are not answering the question of the OP
joaquin
Yes, he is and very well. Lark is just following the mod_python tutorial, so it is very relevant to point him to mod_wsgi and save him some hair pulling.
Frank Malina
A: 

I figured it out. My Directory did not match my DocumentRoot.

I appreciate the replies regarding mod_wsgi. I will eventually move to wsgi but I am still learning how to use Python for web development and I basically defaulted to learn using mod_python.

Lark
Bad choice. Switch now so you can focus on web development, not administration of a product that's not used much.
S.Lott