Commit d7e6ca48 authored by Rafael Monnerat's avatar Rafael Monnerat

update_data use len(data) when size is None, which breaks this method (setData).

define size = 0 when data is None, will prevent len be use update_data and keep the consistency of getData() and setData().

Other alternative should monkey patch update_data or avoid his usage removing "if/else". 



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29036 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 53d8eff0
......@@ -1416,11 +1416,17 @@ class Document(PermanentURLMixIn, XMLObject, UrlMixIn, ConversionCacheMixin, Sna
be a interface for all classes which can act as a File.
"""
size = None
# update_data use len(data) when size is None, which breaks this method.
# define size = 0 will prevent len be use and keep the consistency of
# getData() and setData()
if data is None:
size = 0
if not isinstance(data, Pdata) and data is not None:
file = cStringIO.StringIO(data)
data, size = self._read_data(file)
if getattr(self, 'update_data', None) is not None:
self.update_data(data, size=size) # We call this method to make sure size is set and caches reset
# We call this method to make sure size is set and caches reset
self.update_data(data, size=size)
else:
self._baseSetData(data) # XXX - It would be better to always use this accessor
self.size=size # Using accessor or caching method would be better
......
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