Commit 69504848 authored by Ayush Tiwari's avatar Ayush Tiwari

bt5_config: Return change_list instead of returning error_list after comparing states

parent 5061da1f
...@@ -2052,14 +2052,12 @@ class TemplateTool (BaseTool): ...@@ -2052,14 +2052,12 @@ class TemplateTool (BaseTool):
installation_process._setObject(new_id, aq_base(item), installation_process._setObject(new_id, aq_base(item),
suppress_events=True) suppress_events=True)
error_list = self.compareOldStateToOFS(installation_process, old_installation_state) change_list = self.compareOldStateToOFS(installation_process, old_installation_state)
# Change status of all BM installed if change_list:
for bm in bm_list: change_list = [(l[0].item_path, l[1]) for l in change_list]
bm.setStatus('installed')
if error_list: return change_list
raise ValueError(' '.join(error_list))
installMultipleBusinessManager = updateInstallationState installMultipleBusinessManager = updateInstallationState
...@@ -2160,7 +2158,9 @@ class TemplateTool (BaseTool): ...@@ -2160,7 +2158,9 @@ class TemplateTool (BaseTool):
to_update_path_list = installation_process.getPathList() to_update_path_list = installation_process.getPathList()
portal = self.getPortalObject() portal = self.getPortalObject()
error_list = [] # List to store what changes will be done to which path. Here we compare
# with all the states (old version, new version and state of object at ZODB)
change_list = []
to_update_path_list = self.sortPathList(to_update_path_list) to_update_path_list = self.sortPathList(to_update_path_list)
...@@ -2212,14 +2212,14 @@ class TemplateTool (BaseTool): ...@@ -2212,14 +2212,14 @@ class TemplateTool (BaseTool):
if new_item.getProperty('item_sha') == obj_sha: if new_item.getProperty('item_sha') == obj_sha:
if int(new_item.getProperty('item_sign')) == -1: if int(new_item.getProperty('item_sign')) == -1:
# If the sign is negative, remove the value from the path # If the sign is negative, remove the value from the path
new_item.install(installation_process) change_list.append((new_item, 'Removing'))
else: else:
# If same hash, and +1 sign, do nothing # If same hash, and +1 sign, do nothing
continue continue
else: else:
# Install the new_item # Install the new_item
new_item.install(installation_process) change_list.append((new_item, 'Adding'))
else: else:
# Change at ZODB, so get the new item # Change at ZODB, so get the new item
...@@ -2231,8 +2231,8 @@ class TemplateTool (BaseTool): ...@@ -2231,8 +2231,8 @@ class TemplateTool (BaseTool):
continue continue
else: else:
# Raise error # Trying to update change at ZODB
error_list.append('Trying to remove changes at ZODB at %s' % path) change_list.append((new_item, 'Updating'))
else: else:
# Object created at ZODB by the user # Object created at ZODB by the user
...@@ -2244,8 +2244,8 @@ class TemplateTool (BaseTool): ...@@ -2244,8 +2244,8 @@ class TemplateTool (BaseTool):
continue continue
else: else:
# Raise error # Trying to update change at ZODB
error_list.append('Trying to remove changes at ZODB at %s' % path) change_list.append((new_item, 'Updating'))
except (AttributeError, KeyError) as e: except (AttributeError, KeyError) as e:
# Get item at old state # Get item at old state
...@@ -2259,7 +2259,8 @@ class TemplateTool (BaseTool): ...@@ -2259,7 +2259,8 @@ class TemplateTool (BaseTool):
# Check sign of new_item # Check sign of new_item
if int(new_item.getProperty('item_sign')) == 1: if int(new_item.getProperty('item_sign')) == 1:
error_list.append('Object at %s removed by user' % path) # Object at ZODB has been removed by the user
change_item.append((new_item, 'Adding'))
else: else:
# If there is no item at old state, install the new_item # If there is no item at old state, install the new_item
...@@ -2272,9 +2273,10 @@ class TemplateTool (BaseTool): ...@@ -2272,9 +2273,10 @@ class TemplateTool (BaseTool):
value = new_item.objectValues()[0] value = new_item.objectValues()[0]
except IndexError: except IndexError:
continue continue
new_item.install(installation_process) # Installing a new item
change_list.append((new_item, 'Adding'))
return error_list return change_list
def getInstalledBusinessManagerList(self): def getInstalledBusinessManagerList(self):
bm_list = self.objectValues(portal_type='Business Manager') bm_list = self.objectValues(portal_type='Business Manager')
......
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