From b985124befb353c22504b5014a79dd5edd006cfa Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Mon, 26 Dec 2022 10:33:12 -0600 Subject: [PATCH] Fix product image view for python3 --- tailbone/views/products.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tailbone/views/products.py b/tailbone/views/products.py index 0e6321fd..a7110660 100644 --- a/tailbone/views/products.py +++ b/tailbone/views/products.py @@ -45,7 +45,6 @@ from rattail.time import localtime, make_utc import colander from deform import widget as dfwidget -from pyramid import httpexceptions from webhelpers2.html import tags, HTML from tailbone import forms, grids @@ -828,7 +827,7 @@ class ProductView(MasterView): price = self.Session.query(model.ProductPrice).get(key) if price: return price.product - raise httpexceptions.HTTPNotFound() + raise self.notfound() def configure_form(self, f): super(ProductView, self).configure_form(f) @@ -1757,10 +1756,13 @@ class ProductView(MasterView): """ product = self.get_instance() if not product.image: - raise httpexceptions.HTTPNotFound() + raise self.notfound() # TODO: how to properly detect image type? - # self.request.response.content_type = six.binary_type('image/png') - self.request.response.content_type = six.binary_type('image/jpeg') + # content_type = 'image/png' + content_type = 'image/jpeg' + if not six.PY3: + content_type = six.binary_type(content_type) + self.request.response.content_type = content_type self.request.response.body = product.image.bytes return self.request.response