Commit fccc263c authored by Vincent Pelletier's avatar Vincent Pelletier

Make generateBarcodeImage reusable from any script.

Only set response headers when published alone.
Also, do not set Content-Length, as Zope can set it by itself.
parent a5148a80
def generateBarcodeImage(self, barcode_type, data):
def generateBarcodeImage(self, barcode_type, data, REQUEST=None):
# huBarcode's DataMatrix support has limitation for data size.
# huBarcode's QRCode support is broken.
# more 1-D barcode types can be added by pyBarcode library.
......@@ -30,7 +30,6 @@ def generateBarcodeImage(self, barcode_type, data):
output = fp.read()
else:
raise NotImplementedError, 'barcode_type=%s is not supported' % barcode_type
RESPONSE = self.REQUEST.RESPONSE
RESPONSE.setHeader('Content-Type', 'image/png')
RESPONSE.setHeader('Content-Length', len(output))
if REQUEST is not None:
REQUEST.RESPONSE.setHeader('Content-Type', 'image/png')
return output
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment