[mod_python] req.write - display in same page

Prashanth prashanth.dumpuri at vanderbilt.edu
Thu Apr 19 22:44:39 EDT 2007


Graham and Roberto,
Apologies for not being clear in my earlier post.

The following is a part of my HTML code (called index.html) that accepts 
a file from users, reads and then processes it

<form action="python/cgi-bin/getFile" method="post" 
enctype="multipart/form-data">
<input type="file" name="file" />
<input type="submit" name="submit" value="Submit" />
</form>

Here's my python script (readFile.py) that handles reading the file 
(that is uploaded by the user)

from mod_python import apache
from mod_python.util import FieldStorage
def handler(req):
req.content_type = "text/plain"
form = FieldStorage(req)
for field in form.list:
fname = field.filename
ext = fname.split(".")

# desired file extension for me is .nml
if (ext != ".nml):
req.write("Please input a file with .nml extension")
else:
req.write("File has the desired extension..proceeding to process it")


The way it stands req.write is printing the messages in a reloaded 
window/ fresh page. Is there a way to print messages from req.write in 
the same page ? In other words, req.write is writing its messages to 
http://localhost/index.html/readFile.py. Can I force req.write to write 
the messages to http://localhost/index.html ?

Thanks
Prashanth





More information about the Mod_python mailing list