Commit e101a0e8 authored by Rafael Monnerat's avatar Rafael Monnerat

Fix "Speed up Optimization"

use by using "self" on transactional_cached decorator breaks ERP5Site creation due aq_base.
parent a4ed1a23
...@@ -877,57 +877,62 @@ class TemplateTool (BaseTool): ...@@ -877,57 +877,62 @@ class TemplateTool (BaseTool):
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getDependencyList') 'getDependencyList')
@transactional_cached(lambda self, bt: (self, 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)
""" """
# We do not take into consideration the dependencies # use by using "self" on transactional_cached decorator
# for meta business templates # breaks ERP5Site creation due aq_base.
if bt[0] == 'meta': @transactional_cached(lambda bt: (bt))
return [] def _getDependency(bt):
result_list = [] # We do not take into consideration the dependencies
for repository, property_dict_list in self.repository_dict.items(): # for meta business templates
if repository == bt[0]: if bt[0] == 'meta':
for property_dict in property_dict_list: return []
if property_dict['id'] == bt[1]: result_list = []
dependency_list = [q for q in property_dict['dependency_list'] if q] for repository, property_dict_list in self.repository_dict.items():
for dependency_couple in dependency_list: if repository == bt[0]:
# dependency_couple is like "erp5_xhtml_style (>= 0.2)" for property_dict in property_dict_list:
dependency_couple_list = dependency_couple.split(' ', 1) if property_dict['id'] == bt[1]:
dependency = dependency_couple_list[0] dependency_list = [q for q in property_dict['dependency_list'] if q]
version_restriction = None for dependency_couple in dependency_list:
if len(dependency_couple_list) > 1: # dependency_couple is like "erp5_xhtml_style (>= 0.2)"
version_restriction = dependency_couple_list[1] dependency_couple_list = dependency_couple.split(' ', 1)
if version_restriction.startswith('('): dependency = dependency_couple_list[0]
# Something like "(>= 1.0rc6)". version_restriction = None
version_restriction = version_restriction[1:-1] if len(dependency_couple_list) > 1:
require_update = False version_restriction = dependency_couple_list[1]
if dependency not in result_list: if version_restriction.startswith('('):
# Get the lastest version of the dependency on the # Something like "(>= 1.0rc6)".
# repository that meet the version restriction version_restriction = version_restriction[1:-1]
provider_installed = False require_update = False
bt_dep = None if dependency not in result_list:
try: # Get the lastest version of the dependency on the
bt_dep = self.getLastestBTOnRepos(dependency, version_restriction) # repository that meet the version restriction
except BusinessTemplateUnknownError: provider_installed = False
raise BusinessTemplateMissingDependency, 'While analysing %s the following dependency could not be satisfied: %s (%s)\nReason: Business Template could not be found in the repositories'%(bt[1], dependency, version_restriction or '') bt_dep = None
except BusinessTemplateIsMeta: try:
provider_list = self.getProviderList(dependency) bt_dep = self.getLastestBTOnRepos(dependency, version_restriction)
for provider in provider_list: except BusinessTemplateUnknownError:
if self.portal_templates.getInstalledBusinessTemplate(provider) is not None: raise BusinessTemplateMissingDependency, 'While analysing %s the following dependency could not be satisfied: %s (%s)\nReason: Business Template could not be found in the repositories'%(bt[1], dependency, version_restriction or '')
bt_dep = self.getLastestBTOnRepos(provider) except BusinessTemplateIsMeta:
break provider_list = self.getProviderList(dependency)
if bt_dep is None: for provider in provider_list:
bt_dep = ('meta', dependency) if self.portal_templates.getInstalledBusinessTemplate(provider) is not None:
sub_dep_list = self.getDependencyList(bt_dep) bt_dep = self.getLastestBTOnRepos(provider)
for sub_dep in sub_dep_list: break
if sub_dep not in result_list: if bt_dep is None:
result_list.append(sub_dep) bt_dep = ('meta', dependency)
result_list.append(bt_dep) sub_dep_list = self.getDependencyList(bt_dep)
return result_list for sub_dep in sub_dep_list:
raise BusinessTemplateUnknownError, 'The Business Template %s could not be found on repository %s'%(bt[1], bt[0]) if sub_dep not in result_list:
result_list.append(sub_dep)
result_list.append(bt_dep)
return result_list
raise BusinessTemplateUnknownError, 'The Business Template %s could not be found on repository %s'%(bt[1], bt[0])
return _getDependency(bt)
def findProviderInBTList(self, provider_list, bt_list): def findProviderInBTList(self, provider_list, bt_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