--- a/src/pyams_content/generations/__init__.py Fri Jan 04 12:20:10 2019 +0100
+++ b/src/pyams_content/generations/__init__.py Fri Jan 04 12:20:34 2019 +0100
@@ -13,26 +13,26 @@
__docformat__ = 'restructuredtext'
import logging
-logger = logging.getLogger("PyAMS (content)")
+from importlib import import_module
from hypatia.text.lexicon import Lexicon
from pyramid.path import DottedNameResolver
+from zope.dublincore.interfaces import IZopeDublinCore
from zope.lifecycleevent import ObjectCreatedEvent
-from zope.dublincore.interfaces import IZopeDublinCore
-from pyams_catalog.index import FieldIndexWithInterface, KeywordIndexWithInterface, DatetimeIndexWithInterface
+from pyams_catalog.index import DatetimeIndexWithInterface, FieldIndexWithInterface, KeywordIndexWithInterface
+from pyams_catalog.interfaces import DATE_RESOLUTION, MINUTE_RESOLUTION
from pyams_catalog.nltk import NltkFullTextProcessor
from pyams_catalog.site import check_required_indexes
-from pyams_catalog.interfaces import MINUTE_RESOLUTION, DATE_RESOLUTION
-from pyams_content.component.theme import ITagsInfo, IThemesInfo, ICollectionsInfo
-from pyams_content.interfaces import IBaseContent, WEBMASTER_ROLE, OWNER_ROLE, PILOT_ROLE, MANAGER_ROLE, \
- CONTRIBUTOR_ROLE
+from pyams_content.component.theme import ICollectionsInfo, ITagsInfo, IThemesInfo
+from pyams_content.interfaces import CONTRIBUTOR_ROLE, IBaseContent, MANAGER_ROLE, OWNER_ROLE, PILOT_ROLE, \
+ WEBMASTER_ROLE
from pyams_content.reference import ReferencesManager
from pyams_content.reference.pictograms import PictogramTable
from pyams_content.root.interfaces import ISiteRootToolsConfiguration
-from pyams_content.shared.common.manager import SharedToolContainer
from pyams_content.shared.common.interfaces import IWfSharedContent
from pyams_content.shared.common.interfaces.types import IWfTypedSharedContent
+from pyams_content.shared.common.manager import SharedToolContainer
from pyams_content.shared.form.interfaces import IFormsManagerFactory
from pyams_content.shared.imagemap.interfaces import IImageMapManagerFactory
from pyams_content.shared.logo.interfaces import ILogosManagerFactory
@@ -45,9 +45,12 @@
from pyams_thesaurus.index import ThesaurusTermsListFieldIndex
from pyams_utils.interfaces.site import ISiteGenerations
from pyams_utils.interfaces.traversing import IPathElements
-from pyams_utils.registry import utility_config, get_global_registry
+from pyams_utils.registry import get_global_registry, utility_config
from pyams_utils.site import check_required_utilities
-from pyams_workflow.interfaces import IWorkflowState, IWorkflowPublicationInfo
+from pyams_workflow.interfaces import IWorkflowPublicationInfo, IWorkflowState
+
+
+logger = logging.getLogger("PyAMS (content)")
def get_fulltext_lexicon(language):
@@ -324,12 +327,18 @@
"""PyAMS content package generations checker"""
order = 100
- generation = 1
+ generation = 2
- @staticmethod
- def evolve(site, current=None):
+ def evolve(self, site, current=None):
"""Check for required utilities, tables and tools"""
check_required_utilities(site, REQUIRED_UTILITIES)
check_required_indexes(site, get_required_indexes())
check_required_tables(site, REQUIRED_TABLES)
check_required_tools(site, ISiteRootToolsConfiguration, REQUIRED_TOOLS)
+
+ if not current:
+ current = 1
+ for generation in range(current, self.generation):
+ module_name = 'pyams_content.generations.evolve{}'.format(generation)
+ module = import_module(module_name)
+ module.evolve(site)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/generations/evolve1.py Fri Jan 04 12:20:34 2019 +0100
@@ -0,0 +1,35 @@
+#
+# 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 pyams_content.component.paragraph import IParagraphContainer, IParagraphContainerTarget
+from pyams_content.shared.logo.interfaces import ILogosParagraph
+from pyams_i18n.interfaces import II18n
+from pyams_utils.container import find_objects_providing
+from pyams_utils.registry import get_local_registry, set_local_registry
+
+
+def evolve(site):
+ """Evolve 2: rename resource annotations"""
+ registry = get_local_registry()
+ try:
+ set_local_registry(site.getSiteManager())
+ for container in find_objects_providing(site, IParagraphContainerTarget):
+ for paragraph in IParagraphContainer(container).values():
+ if not ILogosParagraph.providedBy(paragraph):
+ continue
+ print("Upgrading logos for case study « {} »".format(II18n(container).query_attribute('title')))
+ paragraph.logos = paragraph.references.copy()
+ del paragraph.references
+ finally:
+ set_local_registry(registry)