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

File: workaround that io.BytesIO.tell() returns long on PY2

Unlike StringIO.StringIO().tell() and open().tell(), which all return
int, io.BytesIO().tell() returns long. Because io.BytesIO is used when
uploading files on Zope4, this cause PropertySheetValidity errors when
checking consistency, because Data.size property is expected to be int.
parent 2db8be5f
......@@ -27,6 +27,7 @@
#
##############################################################################
import six
from AccessControl import ClassSecurityInfo
from Products.ERP5Type.Base import WorkflowMethod
from Products.ERP5Type import Permissions, PropertySheet
......@@ -150,6 +151,12 @@ class File(Document, OFS_File):
data.seek(0)
self.manage_upload(data)
security.declarePrivate('update_data')
def update_data(self, *args, **kw):
super(File, self).update_data(*args, **kw)
if six.PY2 and isinstance(self.size, long):
self.size = int(self.size)
security.declareProtected(Permissions.ModifyPortalContent,'setFile')
def setFile(self, data, precondition=None):
self._setFile(data, precondition=precondition)
......
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