Setting filename in a response

2008-07-04 Thread Pavel Skvazh

Rather basic question.
I've got to return a text file.

response.headers['Content-Type'] = 'text/plain'
return 'Hello, cruel world'

The dialog pops out, but the filename is obviously blank and the
browser comes up with some random one. How do i set it manually?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Setting filename in a response

2008-07-04 Thread Alberto Valverde

Pavel Skvazh wrote:
 Rather basic question.
 I've got to return a text file.

 response.headers['Content-Type'] = 'text/plain'
 return 'Hello, cruel world'

 The dialog pops out, but the filename is obviously blank and the
 browser comes up with some random one. How do i set it manually?
   
fname = hello_world.txt
response.headers['Content-Disposition'] = \
'attachment; filename=%s' % fname

Alberto

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---