Commit cb96aee1 authored by Julien Muchembled's avatar Julien Muchembled

ERP5Site.py: get rid of getToolByName

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43490 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 430a99ac
...@@ -26,7 +26,6 @@ from ZPublisher import BeforeTraverse ...@@ -26,7 +26,6 @@ from ZPublisher import BeforeTraverse
from ZPublisher.BaseRequest import RequestContainer from ZPublisher.BaseRequest import RequestContainer
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.CMFDefault.Portal import CMFSite from Products.CMFDefault.Portal import CMFSite
from Products.CMFCore.utils import getToolByName
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.ERP5Type.Core.Folder import FolderMixIn from Products.ERP5Type.Core.Folder import FolderMixIn
from Acquisition import aq_base from Acquisition import aq_base
...@@ -302,11 +301,10 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin): ...@@ -302,11 +301,10 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
if getattr(aq_base(ob), '_updateInternalRelatedContent', None) is not None: if getattr(aq_base(ob), '_updateInternalRelatedContent', None) is not None:
# Make sure there is no activities pending on that object # Make sure there is no activities pending on that object
try: try:
portal_activities = getToolByName(self, 'portal_activities') portal_activities = self.portal_activities
except AttributeError: except AttributeError:
# There is no activity tool pass
portal_activities = None else:
if portal_activities is not None:
if portal_activities.countMessage(path=ob.getPath())>0: if portal_activities.countMessage(path=ob.getPath())>0:
raise ActivityPendingError, 'Sorry, pending activities prevent ' \ raise ActivityPendingError, 'Sorry, pending activities prevent ' \
+ 'changing id at this current stage' + 'changing id at this current stage'
...@@ -531,7 +529,7 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin): ...@@ -531,7 +529,7 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
if enable_sort: if enable_sort:
# language should be cached in Transaction Cache if performance issue # language should be cached in Transaction Cache if performance issue
localizer_tool = getToolByName(self, 'Localizer') localizer_tool = self.Localizer
language = localizer_tool.get_selected_language() language = localizer_tool.get_selected_language()
else: else:
localizer_tool = language = None localizer_tool = language = None
...@@ -1664,11 +1662,11 @@ class ERP5Generator(PortalGenerator): ...@@ -1664,11 +1662,11 @@ class ERP5Generator(PortalGenerator):
# because the API is not the completely same as ERP5Catalog, # because the API is not the completely same as ERP5Catalog,
# and ZCatalog is useless for ERP5 after all. # and ZCatalog is useless for ERP5 after all.
update = kw.get('update', 0) update = kw.get('update', 0)
portal_catalog = getToolByName(p, 'portal_catalog', None) try:
if portal_catalog is not None and \ if p.portal_catalog.meta_type != 'ZSQLCatalog' and not update:
portal_catalog.meta_type != 'ZSQLCatalog' and \
not update:
p._delObject('portal_catalog') p._delObject('portal_catalog')
except AttributeError:
pass
# Add CMF Report Tool # Add CMF Report Tool
if not p.hasObject('portal_report'): if not p.hasObject('portal_report'):
...@@ -1770,7 +1768,7 @@ class ERP5Generator(PortalGenerator): ...@@ -1770,7 +1768,7 @@ class ERP5Generator(PortalGenerator):
if not 'Localizer' in p.objectIds(): if not 'Localizer' in p.objectIds():
addLocalizer = p.manage_addProduct['Localizer'].manage_addLocalizer addLocalizer = p.manage_addProduct['Localizer'].manage_addLocalizer
addLocalizer('', ('en',)) addLocalizer('', ('en',))
localizer = getToolByName(p, 'Localizer') localizer = p.Localizer
addMessageCatalog = localizer.manage_addProduct['Localizer']\ addMessageCatalog = localizer.manage_addProduct['Localizer']\
.manage_addMessageCatalog .manage_addMessageCatalog
if 'erp5_ui' not in localizer.objectIds(): if 'erp5_ui' not in localizer.objectIds():
...@@ -1852,7 +1850,7 @@ class ERP5Generator(PortalGenerator): ...@@ -1852,7 +1850,7 @@ class ERP5Generator(PortalGenerator):
return minimalpath(os.path.join(package_path, subdir)) return minimalpath(os.path.join(package_path, subdir))
import Products.CMFDefault import Products.CMFDefault
ps = getToolByName(p, 'portal_skins') ps = p.portal_skins
# get the layer directories actually present # get the layer directories actually present
for cmfdefault_skin_layer in self.CMFDEFAULT_FOLDER_LIST: for cmfdefault_skin_layer in self.CMFDEFAULT_FOLDER_LIST:
reg_key = generateKey(Products.CMFDefault, reg_key = generateKey(Products.CMFDefault,
...@@ -1862,7 +1860,7 @@ class ERP5Generator(PortalGenerator): ...@@ -1862,7 +1860,7 @@ class ERP5Generator(PortalGenerator):
def setupDefaultSkins(self, p): def setupDefaultSkins(self, p):
from Products.CMFCore.DirectoryView import addDirectoryViews from Products.CMFCore.DirectoryView import addDirectoryViews
from Products.CMFActivity import cmfactivity_globals from Products.CMFActivity import cmfactivity_globals
ps = getToolByName(p, 'portal_skins') ps = p.portal_skins
self.addCMFDefaultDirectoryViews(p) self.addCMFDefaultDirectoryViews(p)
addDirectoryViews(ps, 'skins', cmfactivity_globals) addDirectoryViews(ps, 'skins', cmfactivity_globals)
ps.manage_addProduct['OFSP'].manage_addFolder(id='external_method') ps.manage_addProduct['OFSP'].manage_addFolder(id='external_method')
...@@ -1893,9 +1891,7 @@ class ERP5Generator(PortalGenerator): ...@@ -1893,9 +1891,7 @@ class ERP5Generator(PortalGenerator):
""" """
Set up workflows for business templates Set up workflows for business templates
""" """
tool = getToolByName(p, 'portal_workflow', None) tool = p.portal_workflow
if tool is None:
return
for wf_id in ('business_template_building_workflow', for wf_id in ('business_template_building_workflow',
'business_template_installation_workflow'): 'business_template_installation_workflow'):
if wf_id in tool.objectIds(): if wf_id in tool.objectIds():
...@@ -1917,9 +1913,6 @@ class ERP5Generator(PortalGenerator): ...@@ -1917,9 +1913,6 @@ class ERP5Generator(PortalGenerator):
# Make sure all tools and folders have been indexed # Make sure all tools and folders have been indexed
if not kw.get('reindex', 1): if not kw.get('reindex', 1):
return return
skins_tool = getToolByName(p, 'portal_skins', None)
if skins_tool is None:
return
# When no SQL connection was define on the site, # When no SQL connection was define on the site,
# we don't want to make it crash # we don't want to make it crash
if p.erp5_sql_connection_type is not None: if p.erp5_sql_connection_type is not None:
...@@ -2048,9 +2041,7 @@ class ERP5Generator(PortalGenerator): ...@@ -2048,9 +2041,7 @@ class ERP5Generator(PortalGenerator):
""" """
Install the core part of ERP5 Install the core part of ERP5
""" """
template_tool = getToolByName(p, 'portal_templates', None) template_tool = p.portal_templates
if template_tool is None:
return
if template_tool.getInstalledBusinessTemplate('erp5_core') is None: if template_tool.getInstalledBusinessTemplate('erp5_core') is None:
for bt in ('erp5_property_sheets', 'erp5_core', p.erp5_catalog_storage, for bt in ('erp5_property_sheets', 'erp5_core', p.erp5_catalog_storage,
'erp5_xhtml_style'): 'erp5_xhtml_style'):
......
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