Commit 12515e5b authored by Ayush Tiwari's avatar Ayush Tiwari

bt5_config: Override sub for comparing 2 Business Manager objects

parent 293e0e83
......@@ -320,6 +320,7 @@ class BusinessManager(XMLObject):
"""
Adds the Business Item objects for the given Business Manager objects
"""
import pdb; pdb.set_trace()
self._path_item_list.extend(other._path_item_list)
template_path_list = list(self.template_path_list)+list(other.template_path_list)
self.template_path_list = template_path_list
......@@ -327,6 +328,18 @@ class BusinessManager(XMLObject):
__radd__ = __add__
def __sub__(self, other):
"""
Override subtract to find difference b/w the values in different cases.
"""
# Reverse the sign of Business Item objects for the old Business Manager
for path_item in other._path_item_list:
path_item._sign = -1
self._path_item_list.append(path_item)
return self
__rsub__ = __add__
security.declareProtected(Permissions.ManagePortal, 'storeTemplateData')
def storeTemplateData(self):
"""
......@@ -787,7 +800,6 @@ class BusinessItem(Implicit, Persistent):
return merged_value
def _guessFilename(self, document, key, data):
"""
Try to guess the extension based on the id of the document
......
......@@ -314,6 +314,7 @@ class TemplateTool (BaseTool):
self.deleteContent(id)
self._importObjectFromFile(StringIO(export_string), id=id)
security.declareProtected( Permissions.ManagePortal, 'manage_download' )
def manage_download(self, url, id=None, REQUEST=None):
"""The management interface for download.
......@@ -1690,9 +1691,52 @@ class TemplateTool (BaseTool):
"""
Run installation on flattened Business Manager
"""
combinedBM = self.combineMultipleBusinessManager(bm_list)
final_bm_list = []
installed_bm_list = self.getInstalledBusinessManagerList()
installed_bm_title_list = self.getInstalledBusinessManagerTitleList()
installed_bm_dict = dict(zip(installed_bm_title_list, installed_bm_list))
import pdb; pdb.set_trace()
for bm in bm_list:
if bm.title in installed_bm_title_list:
# Not very suitable way to look for already installed BM
installed_bm = installed_bm_dict[bm.title]
# XXX: Installed BM is already reduced. For the Business Manager we
# are planning to install, we should reduce it also.
compared_bm = self.compareBusinessManager(bm, installed_bm)
final_bm_list.append(compared_bm)
else:
final_bm_list.append(bm)
combinedBM = self.combineMultipleBusinessManager(final_bm_list)
self.installBusinessManager(combinedBM)
# Explicilty change the status of Business Manager which are installed
for bm in bm_list:
bm.setStatus('installed')
def getInstalledBusinessManagerList(self):
bm_list = self.objectValues(portal_type='Business Manager')
installed_bm_list = [bm for bm in bm_list if bm.getStatus() == 'installed']
return installed_bm_list
def getInstalledBusinessManagerTitleList(self):
installed_bm_list = self.getInstalledBusinessManagerList()
if not len(installed_bm_list):
return []
installed_bm_title_list = [bm.title for bm in installed_bm_list]
return installed_bm_title_list
security.declareProtected(Permissions.ManagePortal,
'compareMultipleBusinessManager')
def compareBusinessManager(self, new_bm, old_bm):
"""
Compare two business manager and return a new Business manager based on
the difference. This is specially required to comapre two versions of
Business Manager(s).
"""
compared_bm = new_bm-old_bm
return compared_bm
security.declareProtected(Permissions.ManagePortal,
'getBusinessTemplateUrl')
......
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