[mod_python] Try # 2: Mod_python.publisher behavior - sending .py file to browser - Still !

Geoff Skerrett geoff at teammsa.com
Sun May 7 03:24:51 EDT 2006


Gentlemen thanks for you help, and I hope you will be patient with me.  I
have solved the problem and while I know why it works, I am not sure why my
solution was required as the documentation and your responses don't seem to
suggest it as being needed.

Explaination:
I modified the settings in my http.conf file for the directory as suggested
and of course restarted the server.  For this directory the setting are now
as follows;

<Directory "C:\Program Files\Apache Group\Apache2\htdocs\app/"> 
    SetHandler mod_python
    PythonHandler mod_python.publisher
    PythonDebug On 
</Directory> 

I created a very simple program index.py program to help me understand the
behavior.  
It is as follows;

### Begin index.py

def index(req):
	req.write("I am in index()")
	
def bar(req):
	req.write("I am in bar()")

### End index.py

In the browser if I type the following Http://localhost/app/index
The browser displays: "I am in index()"

In the browser if I type the following Http://localhost/app/index/bar
The browser displays: "I am in bar()"

In the browser if I type the following Http://localhost/app/bar
The browser displays: "I am in bar()"

However ...
In the browser if I type the following Http://localhost/app/
The brower displays the file download page and says it is trying to open a
"httpd/unix-directory" file.  If I save this file and view it, the contents
are:
"I am in index()"

So ... mod_python.publisher appears to be working correctly for all cases,
except in the case where I think that it should automatically default to
finding function "index()" within the module "index.py".  

If I modify my example program as follows;

### Begin index.py

def index(req):
	req.content_type = "text/plain"
	req.write("I am in index()")
	
def bar(req):
	req.write("I am in bar()")

### End index.py

Then the URI Http://localhost/app/ work file and displays "I am in index()
in the browser.

So after that long winded explanation ... Is there an addition/extra setting
in the http.conf file that I should be making to make the URI resolution
work properly without having to set the content_type ?  As I mentioned at
the top, the docs don't seem to suggest the *content_type* setting as being
a requirement.

Glad I got I working though ... Now off to some more serious development
issues !

Geoff.



More information about the Mod_python mailing list