Commit 5ed6a0fe authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

sort business templates recursively, without possibly adding additional...

sort business templates recursively, without possibly adding additional business templates, that is already handled by TemplateTool_installRepositoryBusinessTemplateList.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43169 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e26ec3db
...@@ -966,19 +966,33 @@ class TemplateTool (BaseTool): ...@@ -966,19 +966,33 @@ class TemplateTool (BaseTool):
'sortBusinessTemplateList') 'sortBusinessTemplateList')
def sortBusinessTemplateList(self, bt_list): def sortBusinessTemplateList(self, bt_list):
""" """
Sort a list of bt according to dependencies Sort a list of business template in repositories according to
dependencies
bt_list : list of (repository, id) tuple.
""" """
result_list = [] def isDepend(a, b):
for repository, id in bt_list: # return True if a depends on b.
dependency_list = self.getDependencyList((repository, id)) dependency_list = [x.split(' ')[0] for x in a['dependency_list']]
dependency_list.append((repository, id)) provision_list = list(b['provision_list']) + [b['title']]
for dependency in dependency_list: for i in provision_list:
if dependency[0] == 'meta': if i in dependency_list:
provider_list = self.getProviderList(dependency[1]) return True
dependency = self.findProviderInBTList(provider_list, bt_list) return False
if dependency not in result_list:
result_list.append(dependency) sorted_bt_list = []
return result_list for repository, bt_id in bt_list:
bt = [x for x in self.repository_dict[repository] \
if x['id'] == bt_id][0]
for j in range(len(sorted_bt_list)):
if isDepend(sorted_bt_list[j][1], bt):
sorted_bt_list.insert(j, (repository, bt))
break
else:
sorted_bt_list.append((repository, bt))
sorted_bt_list = [(repository, bt['id']) for repository, bt \
in sorted_bt_list]
return sorted_bt_list
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'getRepositoryBusinessTemplateList' ) 'getRepositoryBusinessTemplateList' )
......
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