Python3 fixes: avoid bytes objects in resource content types and filenames
This commit is contained in:
parent
ba5cba6719
commit
b457e3ba37
2 changed files with 6 additions and 0 deletions
|
|
@ -57,6 +57,8 @@ class MediaAsset(MediaAssetFile, ExternalFileAdapter):
|
||||||
data = property(ExternalFileAdapter.getData, setData)
|
data = property(ExternalFileAdapter.getData, setData)
|
||||||
|
|
||||||
def setExternalAddress(self, addr):
|
def setExternalAddress(self, addr):
|
||||||
|
if isinstance(addr, bytes):
|
||||||
|
addr = addr.decode('UTF-8')
|
||||||
ExternalFileAdapter.setExternalAddress(self, addr)
|
ExternalFileAdapter.setExternalAddress(self, addr)
|
||||||
if addr and self.getMimeType().startswith('image/'):
|
if addr and self.getMimeType().startswith('image/'):
|
||||||
self.transform(self.rules)
|
self.transform(self.rules)
|
||||||
|
|
|
||||||
|
|
@ -550,6 +550,8 @@ class IndexAttributes(object):
|
||||||
txt = transformToText(actx)
|
txt = transformToText(actx)
|
||||||
if txt is not None:
|
if txt is not None:
|
||||||
return txt
|
return txt
|
||||||
|
if isinstance(actx.contentType, bytes):
|
||||||
|
actx.contentType = actx.contentType.decode('UTF-8')
|
||||||
if not actx.contentType.startswith('text'):
|
if not actx.contentType.startswith('text'):
|
||||||
return u''
|
return u''
|
||||||
data = actx.data
|
data = actx.data
|
||||||
|
|
@ -613,6 +615,8 @@ def transformToText(obj, data=None, contentType=None):
|
||||||
data = obj.data
|
data = obj.data
|
||||||
if contentType is None:
|
if contentType is None:
|
||||||
contentType = obj.contentType
|
contentType = obj.contentType
|
||||||
|
if type(contentType) == bytes:
|
||||||
|
contentType = contentType.decode('UTF-8')
|
||||||
transform = component.queryAdapter(obj, ITextTransform, name=contentType)
|
transform = component.queryAdapter(obj, ITextTransform, name=contentType)
|
||||||
if transform is not None:
|
if transform is not None:
|
||||||
#rfa = component.queryAdapter(IReadFile, obj)
|
#rfa = component.queryAdapter(IReadFile, obj)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue