[mod_python] FW:

Jim Gallacher jpg at jgassociates.ca
Fri Jul 27 09:43:57 EDT 2007


Jed Drury -X (jedrury - Manpower at Cisco) wrote:
>  
> 
> -----Original Message-----
> From: jed drury [mailto:jeddrury at yahoo.com] 
> Sent: Thursday, July 26, 2007 11:39 PM
> To: jedrury at cisco.com
> Subject: 
> 
> Hello All,
> I am on the verge of configuring this correctly.  I just need a little bit
> more info. in order to get it right.
> 
> First of all, my http.conf looks legit, at least Apache has allowed me to
> restart when I added the necessary "LoadModule"/"Directory" lines per
> Mod_Python.org. However, every time I try to run it through Mozilla using
> the correct path file:
> 
> c:/ApacheGroup/Apache2.2/htdocs/mptest.py
> 
> I always get a "Firefox doesn't know how to open this address, because the
> protocol isn't associated with any program"
> 
> When I tried:
> 
> http://localhost/mptest.py
> 
> The source code showed up on the Mozilla.
> 
> Also, when I tried IE, I got this same response when I
> entered:
> 
> c:/ApacheGroup/Apache2.2/htdocs/mptest.py
> 
> Thanks
> Jed
> Pardon my inexperience and naivite regarding this matter.
> 
> 


You configuration is wrong if your mptest.py file is "C:/Apache 
Group/Apache2.2/htdocs/mptest.py".

<Directory  "C:/Apache Group/Apache2.2/htdocs/mptest">
         AddHandler mod_python .py
         PythonHandler mptest
         PythonDebug On
</Directory>


Either create a directory C:/Apache Group/Apache2.2/htdocs/mptest and 
move mptest.py into it (which is the best plan), or if you want to set 
the handler for your complete htdocs tree use:

<Directory  "C:/Apache Group/Apache2.2/htdocs">
         AddHandler mod_python .py
         PythonHandler mptest
         PythonDebug On
</Directory>

For this config make sure your script "C:/Apache 
Group/Apache2.2/htdocs/mptest.py" exits.

Also, make sure you set the content type in your handler:

mptest.py
---------

from mod_python import apache

def handler(req):
     req.content_type = 'text/plain'
     req.write("Success!")
     return apache.OK

Jim



More information about the Mod_python mailing list