Commit 7784f78c authored by Xiaowu Zhang's avatar Xiaowu Zhang

BusinessTemplate: File 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):
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'
......@@ -3401,6 +3402,9 @@ 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_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