Commit 7f73b507 authored by Julien Muchembled's avatar Julien Muchembled

Fix TemplateTool.getDependencyList()

In particular, 'transactional_cached' decorator was a noop the way it was used.

This reapplies commit d806bdae,
along with a fix to test_resolveBusinessTemplateListDependency.
parent c4f40bc5
...@@ -878,19 +878,15 @@ class TemplateTool (BaseTool): ...@@ -878,19 +878,15 @@ class TemplateTool (BaseTool):
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getDependencyList') 'getDependencyList')
@transactional_cached(lambda self, bt: bt)
def getDependencyList(self, bt): def getDependencyList(self, bt):
""" """
Return the list of missing dependencies for a business Return the list of missing dependencies for a business
template, given a tuple : (repository, id) template, given a tuple : (repository, id)
""" """
# use by using "self" on transactional_cached decorator # We do not take into consideration the dependencies
# breaks ERP5Site creation due aq_base. # for meta business templates
@transactional_cached(lambda bt: (bt)) if bt[0] != 'meta':
def _getDependency(bt):
# We do not take into consideration the dependencies
# for meta business templates
if bt[0] == 'meta':
return []
result_list = [] result_list = []
for repository, property_dict_list in self.repository_dict.items(): for repository, property_dict_list in self.repository_dict.items():
if repository == bt[0]: if repository == bt[0]:
...@@ -920,7 +916,7 @@ class TemplateTool (BaseTool): ...@@ -920,7 +916,7 @@ class TemplateTool (BaseTool):
except BusinessTemplateIsMeta: except BusinessTemplateIsMeta:
provider_list = self.getProviderList(dependency) provider_list = self.getProviderList(dependency)
for provider in provider_list: for provider in provider_list:
if self.portal_templates.getInstalledBusinessTemplate(provider) is not None: if self.getInstalledBusinessTemplate(provider) is not None:
bt_dep = self.getLastestBTOnRepos(provider) bt_dep = self.getLastestBTOnRepos(provider)
break break
if bt_dep is None: if bt_dep is None:
...@@ -932,8 +928,7 @@ class TemplateTool (BaseTool): ...@@ -932,8 +928,7 @@ class TemplateTool (BaseTool):
result_list.append(bt_dep) result_list.append(bt_dep)
return result_list return result_list
raise BusinessTemplateUnknownError, 'The Business Template %s could not be found on repository %s'%(bt[1], bt[0]) raise BusinessTemplateUnknownError, 'The Business Template %s could not be found on repository %s'%(bt[1], bt[0])
return []
return _getDependency(bt)
def findProviderInBTList(self, provider_list, bt_list): def findProviderInBTList(self, provider_list, bt_list):
""" """
......
...@@ -449,7 +449,7 @@ class TestTemplateTool(ERP5TypeTestCase): ...@@ -449,7 +449,7 @@ class TestTemplateTool(ERP5TypeTestCase):
# By removing ca1, we remove the choice for the "sql" provider. # By removing ca1, we remove the choice for the "sql" provider.
# Therefore template tool does not know any more what to take for "sql". # Therefore template tool does not know any more what to take for "sql".
template_tool.manage_delObjects(['ca1']) template_tool.manage_delObjects(['ca1'])
self.commit()
self.assertRaises(BusinessTemplateMissingDependency, self.assertRaises(BusinessTemplateMissingDependency,
template_tool.resolveBusinessTemplateListDependency, template_tool.resolveBusinessTemplateListDependency,
bt5_id_list) bt5_id_list)
......
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