Commit 569729fa authored by Arnaud Fontaine's avatar Arnaud Fontaine

py2: TODO.

parent a706fbcc
...@@ -85,7 +85,7 @@ class TranslatedPropertyGetter(BaseGetter): ...@@ -85,7 +85,7 @@ class TranslatedPropertyGetter(BaseGetter):
localizer = instance.getPortalObject().Localizer localizer = instance.getPortalObject().Localizer
message_catalog = getattr(localizer, domain, None) message_catalog = getattr(localizer, domain, None)
if message_catalog is not None: if message_catalog is not None:
return message_catalog.gettext(unicode(value, 'utf8'), lang=self._language).encode('utf8') return message_catalog.gettext(value, lang=self._language)
else: else:
return value return value
......
...@@ -98,8 +98,10 @@ def asString(value): ...@@ -98,8 +98,10 @@ def asString(value):
if value is None: if value is None:
result = '' result = ''
else: else:
if isinstance(value, unicode): if six.PY2 and isinstance(value, unicode):
result = value.encode('utf-8') result = value.encode('utf-8')
elif six.PY3 and isinstance(value, bytes):
result = value.decode('utf-8')
else: else:
result = str(value) result = str(value)
except TypeError: except TypeError:
...@@ -109,6 +111,8 @@ def asString(value): ...@@ -109,6 +111,8 @@ def asString(value):
def asList(value): def asList(value):
""" """
Return the value as a list or a type-specific default value if it fails. Return the value as a list or a type-specific default value if it fails.
XXX-zope4py3: bytes()?
""" """
if isinstance(value, (list, tuple)): if isinstance(value, (list, tuple)):
result = list(value) result = list(value)
......
from zope.interface import implementer from zope.interface import implementer
import six
from Products.PortalTransforms.interfaces import IDataStream from Products.PortalTransforms.interfaces import IDataStream
@implementer(IDataStream) @implementer(IDataStream)
class datastream: class datastream:
"""A transformation datastream packet""" """A transformation datastream packet"""
if six.PY2:
__slots__ = ('name', '_data', '_metadata') __slots__ = ('name', '_data', '_metadata')
def __init__(self, name): def __init__(self, name):
self.__name__ = name self.__name__ = name
......
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