Commit 37e1ab36 authored by Xiaowu Zhang's avatar Xiaowu Zhang

BusinessTemplate: Import Big File's data property as Pdata

parent 969c3e23
......@@ -95,6 +95,7 @@ import threading
from ZODB.broken import Broken, BrokenModified
from Products.ERP5.genbt5list import BusinessTemplateRevision, \
item_name_list, item_set
from OFS.Image import File as OFSFile
CACHE_DATABASE_PATH = None
try:
......@@ -898,6 +899,8 @@ class ObjectTemplateItem(BaseTemplateItem):
obj.__class__.__name__][1:]
if unicode_data:
data = data.decode(obj.output_encoding)
if isinstance(obj, OFSFile) and property_name == "data":
data = obj._read_data(data)[0]
try:
setattr(obj, property_name, data)
except BrokenModified:
......
......@@ -50,6 +50,7 @@ import string
import tempfile
import glob
import sys
from OFS.Image import Pdata
WORKFLOW_TYPE = 'erp5_workflow'
......@@ -7075,8 +7076,14 @@ class TestBusinessTemplate(BusinessTemplateMixin):
self.assertEqual(file_content, expected_file_content)
self.assertEqual(len(file_content), len(expected_file_content))
def stepCheckFileisImportedAsPdata(self, sequence=None, **kw):
self.assertIsInstance(self.portal.portal_templates
.getInstalledBusinessTemplate('erp5_xhtml_style')._skin_item._objects
['portal_skins/erp5_ckeditor/ckeditor/LICENSE.md'].data, Pdata)
def test_text_file_import_export(self):
"""
First Check if file is imported as Pdata, then check the following case:
When importing back ace.js containing a last line with whitespaces only,
the last line was not imported, and thus the file could never been
downloaded completely as its really size was less than the one on the File
......@@ -7084,6 +7091,8 @@ class TestBusinessTemplate(BusinessTemplateMixin):
"""
sequence_list = SequenceList()
sequence_string = """
CheckFileisImportedAsPdata
CreateSkinFolder
CreateTextFile
CheckTextFileContent
......
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