def write_headers(request, filename, header): """ Write the given headers to the current request """ # Here enforce ascii chars and string object as content type header = force_ascii(header) request.response.content_type = str(header) request.response.headerlist.append( ('Content-Disposition', 'attachment; filename="{0}"'.format(force_ascii(filename)))) return request
def write_headers(request, filename, header): """ Write the given headers to the current request """ request.response.content_type = header request.response.headerlist.append( ('Content-Disposition', 'attachment; filename={0}'.format(force_ascii(filename)))) return request
def as_response(self, request): """ Stream the file in the current request's response """ request.response.content_type = self.mimetype request.response.headerlist.append( ('Content-Disposition', 'attachment; filename={0}'.format(force_ascii(self.name)))) request.response.write(self.datas) return request
def test_force_ascii(): assert force_ascii("éco") == u"eco" assert force_ascii(5) == "5" assert force_ascii(u"éco") == "eco"
def filename(self): return u"{0}.csv".format(ascii.force_ascii(self.context.title))