Commit 7ceb0a6e authored by Xiaowu Zhang's avatar Xiaowu Zhang

BusinessTemplate: File's data property is imported as PData

parent 7047b7d8
......@@ -94,6 +94,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:
......@@ -895,6 +896,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:
......@@ -1507,9 +1510,6 @@ class ObjectTemplateItem(BaseTemplateItem):
assert container.meta_type in ('ERP5 Cache Factory',
'ERP5 Cache Bag')
container.getParentValue().updateCache()
elif obj.__class__.__name__ in ('File', 'Image'):
if "data" in obj.__dict__:
File._setData.__func__(obj, obj.data)
elif (container.meta_type == 'CMF Skins Tool') and \
(old_obj is not None):
# Keep compatibility with previous export format of
......
......@@ -50,6 +50,7 @@ import string
import tempfile
import glob
import sys
from OFS.Image import Pdata
WORKFLOW_TYPE = 'erp5_workflow'
......@@ -3401,6 +3402,11 @@ class TestBusinessTemplate(BusinessTemplateMixin):
"""Tests the Title of the Template Tool."""
self.assertEqual('Template Tool', self.getTemplateTool().Title())
def test_00_checkFileisPDataInstance(self):
self.assertIsInstance(self.portal.portal_templates
.getInstalledBusinessTemplate('erp5_xhtml_style')._skin_item._objects
['portal_skins/erp5_ckeditor/ckeditor/LICENSE.md'].data, Pdata)
def test_01_checkNewSite(self):
"""Test Check New Site"""
sequence_list = SequenceList()
......
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