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

WebDAVSupport: py3

parent e182ddbf
...@@ -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,6 +50,9 @@ class TextContent: ...@@ -50,6 +50,9 @@ 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
if six.PY3:
message = email.message_from_bytes(text)
else:
message = email.message_from_string(text) 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