Commit cbe91644 authored by Aurel's avatar Aurel

allow to make diff of objects with the one in zodb


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4965 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1aacac22
......@@ -3215,6 +3215,12 @@ Business Template is a set of definitions, such as skins, portal types and categ
modified_object_list = {}
bt_title = self.getTitle()
# can be call to diff two Business Template in template tool
bt2 = kw.get('compare_to', None)
if bt2 is not None:
installed_bt = bt2
else:
installed_bt = self.portal_templates.getInstalledBusinessTemplate(title=bt_title)
if installed_bt is None:
installed_bt_format = 0 # that will not check for modification
......@@ -3222,7 +3228,8 @@ Business Template is a set of definitions, such as skins, portal types and categ
installed_bt_format = installed_bt.getTemplateFormatVersion()
# if reinstall business template, must compare to object in ZODB
# and not to those in the installed Business Template because it is itself
# and not to those in the installed Business Template because it is itself.
# same if we make a diff and selected only one business template
reinstall = 0
if installed_bt == self:
reinstall = 1
......@@ -3233,11 +3240,6 @@ Business Template is a set of definitions, such as skins, portal types and categ
bt2.build()
installed_bt = bt2
# can be call to diff two Business Template in template tool
bt2 = kw.get('compare_to', None)
if bt2 is not None:
installed_bt = bt2
new_bt_format = self.getTemplateFormatVersion()
if installed_bt_format == 0 and new_bt_format == 0:
# still use old format, so install everything, no choice
......@@ -3259,6 +3261,7 @@ Business Template is a set of definitions, such as skins, portal types and categ
old_item = getattr(installed_bt, item_name, None)
if new_item is not None:
if old_item is not None:
LOG('compare object item', 0, item_name)
modified_object = new_item.preinstall(context=local_configuration, installed_bt=old_item)
if len(modified_object) > 0:
modified_object_list.update(modified_object)
......@@ -3759,8 +3762,18 @@ Business Template is a set of definitions, such as skins, portal types and categ
new_bt =self
# compare with a given business template
compare_to_zodb = 0
bt2_id = kw.get('compare_with', None)
if bt2_id is not None:
if bt2_id == self.getId():
compare_to_zodb = 1
installed_bt = self.getInstalledBusinessTemplate(title=self.getTitle())
bt2 = self.portal_templates.manage_clone(ob=installed_bt, id='installed_bt_for_diff')
# update portal types properties to get last modifications
bt2.getPortalTypesProperties()
bt2.edit(description='tmp bt generated for diff')
installed_bt = bt2
else:
installed_bt = self.portal_templates._getOb(bt2_id)
else:
installed_bt = self.getInstalledBusinessTemplate(title=self.getTitle())
......@@ -3769,6 +3782,8 @@ Business Template is a set of definitions, such as skins, portal types and categ
new_item = getattr(new_bt, item_name)
installed_item = getattr(installed_bt, item_name)
if compare_to_zodb:
installed_item.build(self)
new_object = new_item._objects[object_id]
installed_object = installed_item._objects[object_id]
# make diff
......@@ -3821,6 +3836,9 @@ Business Template is a set of definitions, such as skins, portal types and categ
else:
diff_msg = 'No diff'
if compare_to_zodb:
self.portal_templates.manage_delObjects(ids=['installed_bt_for_diff'])
return diff_msg
......
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