Add default site root factory utility
authorThierry Florac <thierry.florac@onf.fr>
Thu, 22 Mar 2018 14:50:32 +0100
changeset 491 828f9c9303cf
parent 490 30fcd0659601
child 492 04503227569d
Add default site root factory utility
src/pyams_content/root/__init__.py
--- a/src/pyams_content/root/__init__.py	Thu Mar 22 14:48:33 2018 +0100
+++ b/src/pyams_content/root/__init__.py	Thu Mar 22 14:50:32 2018 +0100
@@ -26,7 +26,7 @@
 from pyams_portal.interfaces import IPortalContext
 from pyams_security.interfaces import IDefaultProtectionPolicy, IGrantedRoleEvent, ISecurityManager
 from pyams_utils.interfaces import MANAGE_SYSTEM_PERMISSION
-from pyams_utils.interfaces.site import IConfigurationFactory, IBackOfficeConfigurationFactory
+from pyams_utils.interfaces.site import IConfigurationFactory, IBackOfficeConfigurationFactory, ISiteRootFactory
 from zope.annotation.interfaces import IAnnotations
 
 # import packages
@@ -36,7 +36,7 @@
 from pyams_skin.configuration import Configuration, BackOfficeConfiguration
 from pyams_skin.skin import UserSkinnableContent
 from pyams_utils.adapter import adapter_config, ContextAdapter
-from pyams_utils.registry import get_utility
+from pyams_utils.registry import get_utility, utility_config
 from pyams_utils.site import BaseSiteRoot
 from pyams_utils.traversing import get_parent
 from pyramid.events import subscriber
@@ -57,6 +57,14 @@
     templates_managers = RolePrincipalsFieldProperty(ISiteRootRoles['templates_managers'])
 
 
+@utility_config(provides=ISiteRootFactory)
+class SiteRootFactory(object):
+    """Default site root factory"""
+
+    def __new__(cls):
+        return SiteRoot
+
+
 @implementer(ISiteRootConfiguration)
 class SiteRootConfiguration(Configuration):
     """Site root configuration"""