Commit f286f35e authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

introduce sortDownloadedBusinessTemplateList() that will useful to make...

introduce sortDownloadedBusinessTemplateList() that will useful to make erp5_upgrader more automatic.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43170 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5ed6a0fe
...@@ -994,6 +994,36 @@ class TemplateTool (BaseTool): ...@@ -994,6 +994,36 @@ class TemplateTool (BaseTool):
in sorted_bt_list] in sorted_bt_list]
return sorted_bt_list return sorted_bt_list
security.declareProtected(Permissions.AccessContentsInformation,
'sortDownloadedBusinessTemplateList')
def sortDownloadedBusinessTemplateList(self, id_list):
"""
Sort a list of already downloaded business templates according to
dependencies
id_list : list of business template's id in portal_templates.
"""
def isDepend(a, b):
# return True if a depends on b.
dependency_list = [x.split(' ')[0] for x in a.getDependencyList()]
provision_list = list(b.getProvisionList()) + [b.getTitle()]
for i in provision_list:
if i in dependency_list:
return True
return False
sorted_bt_list = []
for bt_id in id_list:
bt = self._getOb(bt_id)
for j in range(len(sorted_bt_list)):
if isDepend(sorted_bt_list[j], bt):
sorted_bt_list.insert(j, bt)
break
else:
sorted_bt_list.append(bt)
sorted_bt_list = [bt.getId() for bt in sorted_bt_list]
return sorted_bt_list
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'getRepositoryBusinessTemplateList' ) 'getRepositoryBusinessTemplateList' )
def getRepositoryBusinessTemplateList(self, update_only=False, **kw): def getRepositoryBusinessTemplateList(self, update_only=False, **kw):
......
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