Commit b0da70cb authored by Arnaud Fontaine's avatar Arnaud Fontaine

WIP: BusinessTemplate installation.

parent 396d814c
...@@ -141,20 +141,25 @@ SEPARATELY_EXPORTED_PROPERTY_DICT = { ...@@ -141,20 +141,25 @@ SEPARATELY_EXPORTED_PROPERTY_DICT = {
# separate file, with extension specified by 'extension'. # separate file, with extension specified by 'extension'.
# 'extension' must be None for auto-detection. # 'extension' must be None for auto-detection.
# #
# XXX-zope4py3: `text` was added but what we should do is check the
# PropertySheet ('string' (str) /'data' (bytes)) but for now,
# only work on bootstrap...
#
# class_name: (extension, unicode_data, property_name, text), # class_name: (extension, unicode_data, property_name, text),
"Document Component": ("py", 0, "text_content", True ), "Document Component": ("py", 0, "text_content", True ),
"DTMLDocument": (None, 0, "raw", True ), "DTMLDocument": (None, 0, "raw", True ),
"DTMLMethod": (None, 0, "raw", True ), "DTMLMethod": (None, 0, "raw", True ),
"Extension Component": ("py", 0, "text_content", True ), "Extension Component": ("py", 0, "text_content", True ),
"File": (None, 0, "data", lambda obj: (obj.content_type.startswith('text/') or # OFS.File raises ValueError("Must be bytes")
obj.content_type in ('application/javascript', "File": (None, 0, "data", False), # lambda obj: (obj.content_type.startswith('text/') or
'application/js', # obj.content_type in ('application/javascript',
'application/json', # 'application/js',
'application/schema+json', # 'application/json',
'application/x-javascript', # 'application/schema+json',
'application/xml', # 'application/x-javascript',
'application/x-php', # 'application/xml',
'image/svg+xml'))), # 'application/x-php',
# 'image/svg+xml'))),
"Image": (None, 0, "data", False), "Image": (None, 0, "data", False),
"Interface Component": ("py", 0, "text_content", True ), "Interface Component": ("py", 0, "text_content", True ),
"OOoTemplate": ("oot", 1, "_text", True ), "OOoTemplate": ("oot", 1, "_text", True ),
...@@ -5073,7 +5078,7 @@ class bt(dict): ...@@ -5073,7 +5078,7 @@ class bt(dict):
"""Fake 'bt' item to read bt/* files through BusinessTemplateArchive""" """Fake 'bt' item to read bt/* files through BusinessTemplateArchive"""
def _importFile(self, file_name, file): def _importFile(self, file_name, file):
self[file_name] = file.read() self[file_name] = file.read().decode('utf-8')
class BusinessTemplate(XMLObject): class BusinessTemplate(XMLObject):
...@@ -5943,12 +5948,11 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -5943,12 +5948,11 @@ Business Template is a set of definitions, such as skins, portal types and categ
prop_type = prop['type'] prop_type = prop['type']
value = bt_item.get(pid) value = bt_item.get(pid)
if prop_type in ('text', 'string'): if prop_type in ('text', 'string'):
prop_dict[pid] = value.decode('utf-8') if value else '' prop_dict[pid] = value or ''
elif prop_type in ('int', 'boolean'): elif prop_type in ('int', 'boolean'):
prop_dict[pid] = value or 0 prop_dict[pid] = value or 0
elif prop_type in ('lines', 'tokens'): elif prop_type in ('lines', 'tokens'):
prop_dict[pid[:-5]] = (value.decode('utf-8') if value prop_dict[pid[:-5]] = (value or '').splitlines()
else '').splitlines()
self._edit(**prop_dict) self._edit(**prop_dict)
try: try:
......
...@@ -93,7 +93,8 @@ class IdTool(BaseTool): ...@@ -93,7 +93,8 @@ class IdTool(BaseTool):
version_last_generator = 0 version_last_generator = 0
for generator in self.objectValues(): for generator in self.objectValues():
if generator.getReference() == reference: if generator.getReference() == reference:
version = generator.getVersion() # Version Property Sheet defines 'version' property as a 'string'
version = int(generator.getVersion())
if version > version_last_generator: if version > version_last_generator:
id_last_generator = generator.getId() id_last_generator = generator.getId()
version_last_generator = version version_last_generator = version
......
...@@ -94,8 +94,8 @@ def asString(value): ...@@ -94,8 +94,8 @@ def asString(value):
if value is None: if value is None:
result = '' result = ''
else: else:
if isinstance(value, str): if isinstance(value, bytes):
result = value.encode('utf-8') result = value.decode('utf-8')
else: else:
result = str(value) result = str(value)
except TypeError: except TypeError:
...@@ -105,6 +105,8 @@ def asString(value): ...@@ -105,6 +105,8 @@ def asString(value):
def asList(value): def asList(value):
""" """
Return the value as a list or a type-specific default value if it fails. Return the value as a list or a type-specific default value if it fails.
XXX-zope4py3: bytes()?
""" """
if isinstance(value, (list, tuple)): if isinstance(value, (list, tuple)):
result = list(value) result = list(value)
......
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