[mod_python] Problem getting mptest.py to work

Johan C. Stöver java_dev at nilling.nl
Sun Jan 2 05:48:12 EST 2005


add req.content_type="text/html" before rew.write("Hellor World") 

Johan

On Thu, 30 Dec 2004 23:41:09 -0600
Jacob Martinson <dr.martinson at gmail.com> wrote:

> I copied & paisted from the manual...
> 
> root at batman:/var/www/py
> $ cat mptest.py 
> from mod_python import apache
> 
> def handler(req):
>     req.write("Hello World!")
>     return apache.OK
> root at batman:/var/www/py
> $ ls -lh mptest.py 
> -rwxr-xr-x  1 root root 100 2004-12-30 06:10 mptest.py
> 
> 
> On Thu, 30 Dec 2004 08:57:24 -0500, Matthew Krom <mkrom at banta-im.com> wrote:
> > I had a similar problem yesterday -- Apache was displaying the source
> > of the file when I asked for it (sounds similar to your symptom).
> > 
> > The cause in my case was that my py file (mptest.py in your case) did
> > not have a method "def handler(req):".  In my case, I mis-spelled it as
> > "def handle(req)".
> > 
> > Perhaps if mod_python cannot find a handler method, it gives up, and
> > Apache takes over and just serves the source file?
> > 
> > Matt
> > 
> > 
> > > Hello All,
> > >
> > > I'm not a python or apache expert but have set up modpython versions 2
> > > and 3 in the past with varying degrees of success...
> > >
> > > mptest.py is generating the "Hello World" message, but apache is
> > > sending a file named "mptest.py" with "hello world" in it, rather than
> > > sending it in a form where the browser will recognize it directly.
> > >
> > > Firefox, Internet Explorer and lynx will not display it directly, but
> > > will offer to open it with "less".  Another text browser "links" opens
> > > it directly.
> > >
> > > Details of my system:
> > >
> > > debian linux (sarge)
> > > apache - 2.0.52
> > > python - 2.3.4
> > > modpython - 3.1.3
> > >
> > > At the end of my apache2.conf, I have this from the install guide:
> > >
> > > <Directory /var/www/py>
> > >    AddHandler mod_python .py
> > >    PythonHandler mptest
> > >    PythonDebug On
> > > </Directory>
> > >
> > > The module is getting loaded from a string of config file includes,
> > > but I'm pretty sure it is loading because I get this line in the error
> > > log:
> > >
> > > [Thu Dec 30 06:44:00 2004] [notice] mod_python: (Re)importing module
> > > 'mptest'
> > >
> > > Am I missing something?
> > >
> > > Thanks!!!
> > >
> > > -jacob
> > > _______________________________________________
> > > Mod_python mailing list
> > > Mod_python at modpython.org
> > > http://mailman.modpython.org/mailman/listinfo/mod_python
> > >
> > 
> >
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python


-- 
Nilling Software Design
Postbus 43
2280 AA  Rijswijk ZH
w: http://www.nilling.nl


More information about the Mod_python mailing list