Exemple #1
0
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
Exemple #2
0
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
Exemple #3
0
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
Exemple #4
0
 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
Exemple #5
0
 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
Exemple #6
0
def test_force_ascii():
    assert force_ascii("éco") == u"eco"
    assert force_ascii(5) == "5"
    assert force_ascii(u"éco") == "eco"
Exemple #7
0
 def filename(self):
     return u"{0}.csv".format(ascii.force_ascii(self.context.title))
Exemple #8
0
 def filename(self):
     return u"{0}.csv".format(ascii.force_ascii(self.context.title))
def test_force_ascii():
    assert force_ascii("éco") == u"eco"
    assert force_ascii(5) == "5"
    assert force_ascii(u"éco") == "eco"