On Tuesday, February 22, 2011 08:05:41 am Sandeep wrote:
> Dear,
> I am a web developer using extjs at front end and python at back end
> in turbogear environment.
>
> I have some text content in database field. I want to download that
> text content from database field on client machine. I want this text
> content in a file at client side. So browser should prompt for save as
> dialog box and ask for save as file. I am using extjs at client side
> and my web browser is firefox.
>
> In the back end, I do not want to create any physical file on
> webserver.
>
> Please let me know if you have any solution on this issue.
This should get you started:
from tg import expose, response
from tg.controllers import CUSTOM_CONTENT_TYPE
@expose(content_type=CUSTOM_CONTENT_TYPE)
def download__file(self):
rh = response.headers
rh['Content-Type'] = 'application/octet-stream; charset=utf-8'
#response.content_type = 'application/octet-stream'
disposition = 'attachment; filename="filename.ext"'
rh['Content-disposition'] = disposition
rh['Pragma'] = 'public' # for IE
rh['Cache-control'] = 'max-age=0' #for IE
return "these are the file contents"
HTH,
Diez
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en.