[mod_python] req.sendfile(): specifying a name for the file sent?

David Y. Badawi, M.D. davidbadawi at yahoo.com
Mon May 9 19:10:10 EDT 2005

I had a similar issue with mod_python some time back where I had two requirements:
-a txt file had to be generated
-a dynamically generated title for the document (to make saving the document more organized)
I created a handler for handling any URIs ending with '.txt' as opposed to .py or .psp to write out the request. Recall that mod_python doesn't care as much about the file name as it does for the suffix of the file.
My way is pretty hacky-i'd be curious to see what the pyGurus have to suggest.

Calvin Chen <calvin.chen at gmail.com> wrote:

Right now, when I use req.sendfile(), the file download prompt comes
up and asks me if I want to download a file. So far so good. The
contents of this file is exactly how I wanted it to be. So far so

I have this code in example.py:

def index(req):

When the file is sent to the user, the file's default name is the URI
(ie 'example'), and I'd like to specify the filename, for example,
'name.txt' instead of 'example.'

Any ideas?


Mod_python mailing list
Mod_python at modpython.org

David Y. Badawi, M.D.
Northwest Eye Physicians
1588 North Arlington Heights Road
Arlington Heights, Illinois 60004

Phone: 847 392 9220
Fax:     847 392 9252
email:  davidbadawi at yahoo.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20050509/3ad194e2/attachment.html

More information about the Mod_python mailing list