Commit 9f6908ac authored by Aurel's avatar Aurel

BusinessTemplate: when installing tool, register it on the site manager

parent 01e450c1
...@@ -1869,6 +1869,7 @@ class ToolTemplateItem(PathTemplateItem): ...@@ -1869,6 +1869,7 @@ class ToolTemplateItem(PathTemplateItem):
def install(self, context, trashbin, **kw): def install(self, context, trashbin, **kw):
""" When we install a tool that is a type provider not """ When we install a tool that is a type provider not
registered on types tool, register it into the type provider. registered on types tool, register it into the type provider.
We also need to register the tool on the site manager
""" """
PathTemplateItem.install(self, context, trashbin, **kw) PathTemplateItem.install(self, context, trashbin, **kw)
portal = context.getPortalObject() portal = context.getPortalObject()
...@@ -1879,6 +1880,8 @@ class ToolTemplateItem(PathTemplateItem): ...@@ -1879,6 +1880,8 @@ class ToolTemplateItem(PathTemplateItem):
type_container_id not in types_tool.type_provider_list): type_container_id not in types_tool.type_provider_list):
types_tool.type_provider_list = tuple(types_tool.type_provider_list) + \ types_tool.type_provider_list = tuple(types_tool.type_provider_list) + \
(type_container_id,) (type_container_id,)
tool_id_list = list(set(self._objects.keys()) & set(portal._registry_tool_id_list))
portal._registerTools(tool_id_list)
def uninstall(self, context, **kw): def uninstall(self, context, **kw):
""" When we uninstall a tool, unregister it from the type provider. """ """ When we uninstall a tool, unregister it from the type provider. """
......
...@@ -351,26 +351,31 @@ class ERP5Site(ResponseHeaderGenerator, FolderMixIn, PortalObjectBase, CacheCook ...@@ -351,26 +351,31 @@ class ERP5Site(ResponseHeaderGenerator, FolderMixIn, PortalObjectBase, CacheCook
provided=ITranslationDomain, provided=ITranslationDomain,
name=alias) name=alias)
_registry_tool_id_list = 'caching_policy_manager',
def _registerMissingTools(self): def _registerMissingTools(self):
from Products.CMFCore import interfaces, utils
tool_id_list = ("portal_skins", "portal_types", "portal_membership", tool_id_list = ("portal_skins", "portal_types", "portal_membership",
"portal_url", "portal_workflow") "portal_url", "portal_workflow")
if (None in map(self.get, tool_id_list) or not if (None in map(self.get, tool_id_list) or not
TransactionalResource.registerOnce(__name__, 'site_manager', self.id)): TransactionalResource.registerOnce(__name__, 'site_manager', self.id)):
return return
self._registerTools(tool_id_list + self._registry_tool_id_list)
def markRegistered(txn):
global _missing_tools_registered
_missing_tools_registered = self.id
TransactionalResource(tpc_finish=markRegistered)
def _registerTools(self, tool_id_list):
from Products.CMFCore import interfaces, utils
sm = self._components sm = self._components
for tool_id in tool_id_list: for tool_id in tool_id_list:
tool = self[tool_id] tool = self.get(tool_id, None)
if tool:
tool_interface = utils._tool_interface_registry.get(tool_id) tool_interface = utils._tool_interface_registry.get(tool_id)
if tool_interface is not None: if tool_interface is not None:
# Note: already registered tools will be either: # Note: already registered tools will be either:
# - updated # - updated
# - registered again after being unregistered # - registered again after being unregistered
sm.registerUtility(aq_base(tool), tool_interface) sm.registerUtility(aq_base(tool), tool_interface)
def markRegistered(txn):
global _missing_tools_registered
_missing_tools_registered = self.id
TransactionalResource(tpc_finish=markRegistered)
# backward compatibility auto-migration # backward compatibility auto-migration
def getSiteManager(self): def getSiteManager(self):
......
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