src/cm/views/export.py
changeset 57 b32aa76ee411
parent 56 bd8a4ffc7dad
parent 52 9fa013909d9a
child 77 fe91eb717a96
equal deleted inserted replaced
56:bd8a4ffc7dad 57:b32aa76ee411
   100 def _response_download(content, title, mimetype, extension):
   100 def _response_download(content, title, mimetype, extension):
   101     response = HttpResponse(mimetype=mimetype)
   101     response = HttpResponse(mimetype=mimetype)
   102     file_title = title + '.' + extension
   102     file_title = title + '.' + extension
   103     from email.header import Header
   103     from email.header import Header
   104     encoded_name = str(Header(file_title.encode('utf8'), charset='utf8', maxlinelen=500))
   104     encoded_name = str(Header(file_title.encode('utf8'), charset='utf8', maxlinelen=500))
   105     response['Content-Disposition'] = u'attachment; filename=%s' % encoded_name
   105     # TODO: find a way to include long (more than 76 chars) into header
       
   106     encoded_name = encoded_name.replace('\n','')
       
   107     response['Content-Disposition'] = 'attachment; filename=%s' % encoded_name
   106     response.write(content)
   108     response.write(content)
   107     return response        
   109     return response        
   108 
   110 
   109 def _response_write(content):
   111 def _response_write(content):
   110     response = HttpResponse()
   112     response = HttpResponse()