[mod_python] script works, but I need to understand the difference

Graham Dumpleton grahamd at dscpl.com.au
Thu Jan 19 22:53:32 EST 2006


Michael Steinfeld wrote ..
> I gave up on installing mod_python on openbsd temporarily ... if  you
> read my last question.
> 
> Anyhow,
> 
> my apache config looks like this:
> 
> This Works
> ##############################
> AddHandler mod_python .psp .py
> PythonHandler mod_python.psp
> PythonDebug On
> 
> 
> This does not
> ##############################
> AddHandler python-program .py .psp
> PythonHandler mod_python.publisher
> PythonDebug On
> 
> 
> Should I be using mod_python.publisher? or the above? I am confused.

If you want to use both mod_python.publisher and mod_python.psp on
different extensions in the same directory, you will need to use
something like:

AddHandler mod_python .py .psp
PythonHandler mod_python.psp | .psp
PythonHandler mod_python.publisher | .py

Ie., qualify PythonHandler with the extension.

Graham

> Please enlighten me.
> 
> Also,
> 
> Here is a script I wrote which works fine with the above but not
> mod_python.publisher
> the error is below the script
> 
> 
> ############
> #  index.psp  #
> ############
> <html>
> <%
> if form.has_key('name'):
>    greet = 'Hello, %s!' % form['name'].capitalize()
> else:
>    greet = 'Hello there!'
> # end
> %>
>   <h1><%= greet %></h1>
> <%
> import time
> %>
> <h1>Current time is
> <%= time.ctime() %> </h1>
> <%
> import os, sys
> %>
> <h2>Yes, This is a <%= os.name %> based operating system </h2>
> <h2>The platform is: <%= sys.platform %></h2>
> <h3><%= sys.version %></h3>
> <h3><%= os.uname() %></h3>
> <h3>
> <%=
> os.popen( 'uptime' ).read()
> %>
> </h3>
> </html>
> 
> 
> 
> #########################
> Error
> 
> Mod_python error: "PythonHandler mod_python.publisher"
> 
> Traceback (most recent call last):
> 
>   File "/opt/local/lib/python2.4/site-packages/mod_python/apache.py",
> line 299, in HandlerDispatch
>     result = object(req)
> 
>   File "/opt/local/lib/python2.4/site-packages/mod_python/publisher.py",
> line 98, in handler
>     path=[path])
> 
>   File "/opt/local/lib/python2.4/site-packages/mod_python/apache.py",
> line 457, in import_module
>     module = imp.load_module(mname, f, p, d)
> 
>   File "/var/www/htdocs/index.py", line 1
> 
> 
> 
>     ^
> 
> SyntaxError: invalid syntax
> 
> --
> -mike
> 
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python


More information about the Mod_python mailing list