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

py2: TODO.

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