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)
|
||||
|
||||
def setExternalAddress(self, addr):
|
||||
if isinstance(addr, bytes):
|
||||
addr = addr.decode('UTF-8')
|
||||
ExternalFileAdapter.setExternalAddress(self, addr)
|
||||
if addr and self.getMimeType().startswith('image/'):
|
||||
self.transform(self.rules)
|
||||
|
|
|
|||
|
|
@ -550,6 +550,8 @@ class IndexAttributes(object):
|
|||
txt = transformToText(actx)
|
||||
if txt is not None:
|
||||
return txt
|
||||
if isinstance(actx.contentType, bytes):
|
||||
actx.contentType = actx.contentType.decode('UTF-8')
|
||||
if not actx.contentType.startswith('text'):
|
||||
return u''
|
||||
data = actx.data
|
||||
|
|
@ -613,6 +615,8 @@ def transformToText(obj, data=None, contentType=None):
|
|||
data = obj.data
|
||||
if contentType is None:
|
||||
contentType = obj.contentType
|
||||
if type(contentType) == bytes:
|
||||
contentType = contentType.decode('UTF-8')
|
||||
transform = component.queryAdapter(obj, ITextTransform, name=contentType)
|
||||
if transform is not None:
|
||||
#rfa = component.queryAdapter(IReadFile, obj)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue