[mod_python] Installig mod_python on Win XP.

Graham Dumpleton grahamd at dscpl.com.au
Fri May 20 05:29:58 EDT 2005


On 20/05/2005, at 7:10 PM, Oyvind Ostlund wrote:

> Not sure if I added it the right place, but at least I managed to 
> restart Apache afterwards. Then I made a simple python script like 
> this:
>
> ---------------------
> from mod_python import apache
>
>     def handler(req):
>         req.write("Hello World!")
>         return apache.OK
> ---------------------
>
> But if I go to http://localhos/python/ then I get this error message:
>
>
>
> ---------------------
> Mod_python error: "PythonHandler mptest"
>
> Traceback (most recent call last):
>
>   File "C:\PYTHON~1\Lib\site-packages\mod_python\apache.py", line 287, 
> in HandlerDispatch
>     log=debug)
>
>   File "C:\PYTHON~1\Lib\site-packages\mod_python\apache.py", line 457, 
> in import_module
>     module = imp.load_module(mname, f, p, d)
>
>   File "C:/Apache2/htdocs/python/\mptest.py", line 3
>
>     def handler(req):
>
>     ^
>
> SyntaxError: invalid syntax
> ---------------------
>
>
> Does this have anything to do with me not compiling the apache server 
> from scratch with DSO or something. I found some reading about it, at 
> least for Linux, but I have never heard about it before. So is that 
> probably the error, or is it simpler then that?

It is probably because you indented the function definition when you 
shouldn't.
Indenting in Python is very important, more so than other languages.

Also suggest you read through:

   http://www.dscpl.com.au/projects/vampire/articles/modpython-001.html

Use the example code for the handler in that article rather than what 
you
have and it may avoid some other problems described in the article.

Graham



More information about the Mod_python mailing list