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 ...@@ -94,6 +94,7 @@ import threading
from ZODB.broken import Broken, BrokenModified from ZODB.broken import Broken, BrokenModified
from Products.ERP5.genbt5list import BusinessTemplateRevision, \ from Products.ERP5.genbt5list import BusinessTemplateRevision, \
item_name_list, item_set item_name_list, item_set
from OFS.Image import File as OFSFile
CACHE_DATABASE_PATH = None CACHE_DATABASE_PATH = None
try: try:
...@@ -895,6 +896,8 @@ class ObjectTemplateItem(BaseTemplateItem): ...@@ -895,6 +896,8 @@ class ObjectTemplateItem(BaseTemplateItem):
obj.__class__.__name__][1:] obj.__class__.__name__][1:]
if unicode_data: if unicode_data:
data = data.decode(obj.output_encoding) data = data.decode(obj.output_encoding)
if isinstance(obj, OFSFile) and property_name == "data"
data = obj._read_data(data)[0]
try: try:
setattr(obj, property_name, data) setattr(obj, property_name, data)
except BrokenModified: except BrokenModified:
...@@ -1507,9 +1510,6 @@ class ObjectTemplateItem(BaseTemplateItem): ...@@ -1507,9 +1510,6 @@ class ObjectTemplateItem(BaseTemplateItem):
assert container.meta_type in ('ERP5 Cache Factory', assert container.meta_type in ('ERP5 Cache Factory',
'ERP5 Cache Bag') 'ERP5 Cache Bag')
container.getParentValue().updateCache() 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 \ elif (container.meta_type == 'CMF Skins Tool') and \
(old_obj is not None): (old_obj is not None):
# Keep compatibility with previous export format of # Keep compatibility with previous export format of
......
...@@ -50,6 +50,7 @@ import string ...@@ -50,6 +50,7 @@ import string
import tempfile import tempfile
import glob import glob
import sys import sys
from OFS.Image import Pdata
WORKFLOW_TYPE = 'erp5_workflow' WORKFLOW_TYPE = 'erp5_workflow'
...@@ -3401,6 +3402,11 @@ class TestBusinessTemplate(BusinessTemplateMixin): ...@@ -3401,6 +3402,11 @@ class TestBusinessTemplate(BusinessTemplateMixin):
"""Tests the Title of the Template Tool.""" """Tests the Title of the Template Tool."""
self.assertEqual('Template Tool', self.getTemplateTool().Title()) 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): def test_01_checkNewSite(self):
"""Test Check New Site""" """Test Check New Site"""
sequence_list = SequenceList() 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