Commit c03c0f4f authored by Jérome Perrin's avatar Jérome Perrin

fix get_size to use base_data if no data


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16221 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e6aac13f
......@@ -153,10 +153,10 @@ class File(Document, CMFFile, ConversionCacheMixin):
"""
has to be overwritten here, otherwise WebDAV fails
"""
try:
return len(self.data)
except (AttributeError, TypeError):
return 0
data_len = len(getattr(self, 'data', ''))
if not data_len:
data_len = len(self.getBaseData() or '')
return data_len
getcontentlength = get_size
......
......@@ -425,6 +425,21 @@ class TestDocument(ERP5TypeTestCase):
# for REFVER: (3)
# for REFVERLANG: (3)
def testOOoDocument_get_size(self):
# test get_size on OOoDocument
doc = self.portal.document_module.newContent(portal_type='Spreadsheet')
doc.edit(file=makeFileUpload('import_data_list.ods'))
self.assertEquals(len(makeFileUpload('import_data_list.ods').read()),
doc.get_size())
def testTempOOoDocument_get_size(self):
# test get_size on temporary OOoDocument
from Products.ERP5Type.Document import newTempOOoDocument
doc = newTempOOoDocument(self.portal, 'tmp')
doc.edit(base_data='OOo')
self.assertEquals(len('OOo'), doc.get_size())
if __name__ == '__main__':
framework()
else:
......
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