Commit 271ef165 authored by Aurel's avatar Aurel

improve the way that are imported business template properties to take

 new/removed property into account


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4376 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a8c805d1
......@@ -200,15 +200,17 @@ class TemplateTool (BaseTool):
for prop in bt.propertyMap():
type = prop['type']
pid = prop['id']
if pid in ('uid', 'id', 'rid', 'sid', 'id_group', 'last_id', 'dependency_list'):
continue
prop_path = os.path.join(tar.members[0].name, 'bt', pid)
try:
info = tar.getmember(prop_path)
except KeyError:
continue
value = tar.extractfile(info).read()
if type == 'text' or type == 'string' or type == 'int':
prop_dict[pid] = value
elif type == 'lines' or type == 'tokens':
prop_dict[pid[:-5]] = value.split(str(os.linesep))
prop_dict.pop('id', '')
bt.edit(**prop_dict)
# import all other files from bt
fobj = open(path, 'r')
......@@ -245,14 +247,15 @@ class TemplateTool (BaseTool):
for prop in bt.propertyMap():
type = prop['type']
pid = prop['id']
if pid in ('uid', 'id', 'rid', 'sid', 'id_group', 'last_id', 'dependency_list'):
prop_path = os.path.join('.', bt_path, pid)
if not os.path.exists(prop_path):
continue
prop_path = os.path.join(bt_path, pid)
value = open(prop_path, 'r').read()
if type in ('text', 'string', 'int'):
prop_dict[pid] = value
elif type in ('lines', 'tokens'):
prop_dict[pid[:-5]] = value.split(str(os.linesep))
prop_dict.pop('id', '')
bt.edit(**prop_dict)
# import all others objects
bt.importFile(dir=1, file=file_list, root_path=name)
......
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