[mod_python] how to write response in same page

Graham Dumpleton grahamd at dscpl.com.au
Thu Nov 9 16:39:17 EST 2006


=?ISO-8859-15?Q?N=E9stor_Chac=F3n?= Manzano wrote ..
> Hello, i have a little form
> 
> <form action="python/cgi-bin/getFile" method="post" enctype="multipart/form-data">
>    	<input type="file" name="file" />
>    	<input type="submit" name="submit" value="Subir" />
> </form> 
> 
> in /var/www/python/ i have the script that get the information
> 
> from mod_python import apache
> def getFile(req, file=None):
>      req.content_type = "text/html" 
>      if file is None:
>           req.write("Datos Nulos")
>       if type(file) is str:
>           req.write("Datos Erróneos")
>       fileData = file.file.read()    
>       if fileData:
> 	f=open("/tmp/archivo","w")
> 	f.write(fileData)
> 	f.close()
> 	req.write(str(dir(req)))
>       else:
> 	req.write("Archivo vacío")
> 
> When the process executes the "req.write" appears the menssage in a new
> ( reloaded ) window.
> How i can for write the menssage in the same window ( with not reload )
> ?

If I understand what you want correctly, only by embedding some fancy
Javascript in your pages which does sub requests and partial page updates
by manipulating the already drawn page.

I would suggest you do some research into what AJAX is all about. You
might start with the WikiPedia entry:

  http://en.wikipedia.org/wiki/Ajax_(programming)

and go from there.

Graham


More information about the Mod_python mailing list