Commit 0926068e authored by Jérome Perrin's avatar Jérome Perrin

BusinessTemplate: fix export separately on py3

parent 21ab1aab
...@@ -832,16 +832,19 @@ class ObjectTemplateItem(BaseTemplateItem): ...@@ -832,16 +832,19 @@ class ObjectTemplateItem(BaseTemplateItem):
obj = obj._getCopy(context) obj = obj._getCopy(context)
data = getattr(aq_base(obj), record_id, None) data = getattr(aq_base(obj), record_id, None)
if unicode_data: if unicode_data:
if not (six.PY2 and isinstance(data, six.text_type)): if not isinstance(data, six.text_type):
break break
try: try:
data = data.encode(aq_base(obj).output_encoding) data = data.encode(aq_base(obj).output_encoding)
except (AttributeError, UnicodeEncodeError): except (AttributeError, UnicodeEncodeError):
break break
elif type(data) is not bytes: elif type(data) is not bytes:
if not isinstance(data, Pdata): if isinstance(data, str):
data = data.encode()
elif not isinstance(data, Pdata):
break break
data = bytes(data) else:
data = bytes(data)
try: try:
# Delete this attribute from the object. # Delete this attribute from the object.
# in case the related Portal Type does not exist, the object may be broken. # in case the related Portal Type does not exist, the object may be broken.
......
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