Commit d72958b8 authored by Nicolas Dumazet's avatar Nicolas Dumazet

Do not export or import non-existing properties of BT objects.

Example of bad behavior:
 - "short_title" property is not used / has no associated field
 - in export code getProperty('short_title') returns None
 - and a bt/short_title file is created, containing str(None)
 - when reimporting this BT, bt/short_title is read, and obj.short_title is set
    to 'None' string
 - as a result, bt.getShortTitle() wrongly returns "None" _string_



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32926 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent bc983aa2
......@@ -5553,6 +5553,8 @@ Business Template is a set of definitions, such as skins, portal types and categ
'install_object_list_list', 'id_generator', 'bt_for_diff'):
continue
value = self.getProperty(id)
if value is None:
continue
if prop_type in ('text', 'string', 'int', 'boolean'):
bta.addObject(obj=value, name=id, path=path+os.sep+'bt', ext='')
elif prop_type in ('lines', 'tokens'):
......
......@@ -256,6 +256,11 @@ class TemplateTool (BaseTool):
except KeyError:
continue
value = tar.extractfile(info).read()
if value is 'None':
# At export time, we used to export non-existent properties:
# str(obj.getProperty('non-existing')) == 'None'
# Discard them
continue
if prop_type == 'text' or prop_type == 'string' \
or prop_type == 'int':
prop_dict[pid] = value
......@@ -320,6 +325,11 @@ class TemplateTool (BaseTool):
if not os.path.exists(prop_path):
continue
value = open(prop_path, 'rb').read()
if value is 'None':
# At export time, we used to export non-existent properties:
# str(obj.getProperty('non-existing')) == 'None'
# Discard them
continue
if prop_type in ('text', 'string', 'int', 'boolean'):
prop_dict[pid] = value
elif prop_type in ('lines', 'tokens'):
......
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