Updated sitemap to add sitemap extensions adapters
authorThierry Florac <thierry.florac@onf.fr>
Fri, 28 Dec 2018 10:44:50 +0100
changeset 309 cf5d41f5e210
parent 308 44920a031dc0
child 310 9e2e4c39f732
Updated sitemap to add sitemap extensions adapters
src/pyams_default_theme/features/sitemap/__init__.py
src/pyams_default_theme/features/sitemap/interfaces.py
--- a/src/pyams_default_theme/features/sitemap/__init__.py	Fri Dec 28 10:28:33 2018 +0100
+++ b/src/pyams_default_theme/features/sitemap/__init__.py	Fri Dec 28 10:44:50 2018 +0100
@@ -22,14 +22,13 @@
 from zope.intid import IIntIds
 
 from pyams_catalog.query import CatalogResultSet
-from pyams_content.component.theme import ITagsManager
 from pyams_content.root import ISiteRoot, ISiteRootToolsConfiguration
 from pyams_content.shared.common import CONTENT_TYPES, IBaseSharedTool
+from pyams_default_theme.features.sitemap.interfaces import ISitemapExtension
 from pyams_i18n.interfaces import II18nManager
 from pyams_skin.layer import IPyAMSUserLayer
-from pyams_thesaurus.interfaces.thesaurus import IThesaurus
 from pyams_utils.list import unique_iter
-from pyams_utils.registry import get_all_utilities_registered_for, get_utility, query_utility
+from pyams_utils.registry import get_all_utilities_registered_for, get_utility
 from pyams_workflow.interfaces import IWorkflow, IWorkflowPublicationInfo
 
 
@@ -74,11 +73,10 @@
             publication_info = IWorkflowPublicationInfo(tool, None)
             if (publication_info is None) or publication_info.is_visible(self.request):
                 yield timestamp, tool
-        tags_manager = ITagsManager(self.request.root)
-        if tags_manager.enable_glossary:
-            thesaurus = query_utility(IThesaurus, name=tags_manager.glossary_thesaurus_name)
-            if thesaurus is not None:
-                yield timestamp, thesaurus
+        for name, adapter in self.request.registry.getAdapters((self.request.context, self.request), ISitemapExtension):
+            source = adapter.source
+            if source is not None:
+                yield timestamp, source
 
 
 @view_config(name='sitemap.xml', context=IBaseSharedTool, request_type=IPyAMSUserLayer,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_default_theme/features/sitemap/interfaces.py	Fri Dec 28 10:44:50 2018 +0100
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2008-2018 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+from zope.interface import Attribute, Interface
+
+
+class ISitemapExtension(Interface):
+    """Sitemap extension interface"""
+
+    source = Attribute("Sitemap source")