Commit b231df0d authored by Jérome Perrin's avatar Jérome Perrin Committed by Arnaud Fontaine

WebDAVSupport: py3

parent 1496807d
...@@ -23,7 +23,7 @@ from Products.ERP5Type.Globals import InitializeClass ...@@ -23,7 +23,7 @@ from Products.ERP5Type.Globals import InitializeClass
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.CMFCore.PortalContent import ResourceLockedError from Products.CMFCore.PortalContent import ResourceLockedError
from zExceptions import Forbidden from zExceptions import Forbidden
from six.moves import cStringIO as StringIO from io import BytesIO
import six import six
security = ModuleSecurityInfo(__name__) security = ModuleSecurityInfo(__name__)
...@@ -50,7 +50,10 @@ class TextContent: ...@@ -50,7 +50,10 @@ class TextContent:
raise Exception raise Exception
except Exception: except Exception:
# this is probably not html code, try rfc822 parsing # this is probably not html code, try rfc822 parsing
message = email.message_from_string(text) if six.PY3:
message = email.message_from_bytes(text)
else:
message = email.message_from_string(text)
return {k.capitalize(): '\n'.join(message.get_all(k)) return {k.capitalize(): '\n'.join(message.get_all(k))
for k in message.keys()} for k in message.keys()}
...@@ -78,7 +81,7 @@ class TextContent: ...@@ -78,7 +81,7 @@ class TextContent:
headers = self.parseHeadersFromText(body) headers = self.parseHeadersFromText(body)
content_type = REQUEST.get_header('Content-Type', '') content_type = REQUEST.get_header('Content-Type', '')
headers.setdefault('content_type', content_type) headers.setdefault('content_type', content_type)
headers['file'] = StringIO(body) headers['file'] = BytesIO(body)
self._edit(**headers) self._edit(**headers)
except ResourceLockedError: except ResourceLockedError:
transaction.abort() transaction.abort()
......
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