[mod_python] Re[2]: mod_python problem under WinXP

Graham Dumpleton grahamd at dscpl.com.au
Mon Aug 29 01:20:22 EDT 2005


Booboo wrote ..
> > But was there a mod_python startup message in the Apache log file to
> > indicate that mod_python was in fact loaded?
> Hmm... apache starts clearly, i see no messages at all
> 
> > If you are confident that that directory name will work, then use this:
> 
> >    <Directory "D/www/python">
> >       deny from all
> >       AddHandler python-program .py
> >       PythonHandler mptest
> >       PythonDebug on
> >    </Directory>
> 
> I found an error there - forgot to put ":" in D:\ situation changed a
> bit and it writes me in the browser window the following (without deny
> from all of course):
> 
> Hello World!
> <pre>
> Mod_python error: "PythonHandler mptest"
> 
> Traceback (most recent call last):
> 
>   File "C:\PYTHON23\Lib\site-packages\mod_python\apache.py", line 299,
> in HandlerDispatch
>     result = object(req)
> 
>   File "D:/www/python/\mptest.py", line 5, in handler
>     return apache.OK
> 
> NameError: global name 'apache' is not defined
> 
> </pre>
> 
> So i suppose the problem is in the python itself and not in apache or
> .htaccess files. Any suggestions?

You are most likely missing the line "from mod_python import apache".
Use the mptest example exactly as written in the linked document I sent. Ie.,

  from mod_python import apache

  def handler(req):
      req.content_type = 'text/plain'
      req.send_http_header()
      req.write('mptest.py\n')
      return apache.OK

Graham


More information about the Mod_python mailing list