diff --git a/tailbone/views/core.py b/tailbone/views/core.py index a3ec7e2c..56badda3 100644 --- a/tailbone/views/core.py +++ b/tailbone/views/core.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2018 Lance Edgar +# Copyright © 2010-2019 Lance Edgar # # This file is part of Rattail. # @@ -110,7 +110,9 @@ class View(object): if not os.path.exists(path): return self.notfound() response = FileResponse(path, request=self.request) - response.headers[b'Content-Length'] = six.binary_type(os.path.getsize(path)) - filename = os.path.basename(path).encode('ascii', 'replace') - response.headers[b'Content-Disposition'] = b'attachment; filename="{}"'.format(filename) + response.content_length = os.path.getsize(path) + filename = os.path.basename(path) + if six.PY2: + filename = filename.encode('ascii', 'replace') + response.content_disposition = str('attachment; filename="{}"'.format(filename)) return response diff --git a/tailbone/views/purchasing/ordering.py b/tailbone/views/purchasing/ordering.py index 65398ade..af06e4c8 100644 --- a/tailbone/views/purchasing/ordering.py +++ b/tailbone/views/purchasing/ordering.py @@ -36,8 +36,6 @@ from rattail.db import model, api from rattail.core import Object from rattail.time import localtime -from pyramid.response import FileResponse - from tailbone.views.purchasing import PurchasingBatchView @@ -354,10 +352,7 @@ class OrderingBatchView(PurchasingBatchView): path = batch.filepath(self.rattail_config, filename) workbook.save(path) - response = FileResponse(path, request=self.request) - response.content_length = os.path.getsize(path) - response.content_disposition = b'attachment; filename="{}"'.format(filename) - return response + return self.file_response(path) @classmethod def _ordering_defaults(cls, config):