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