diff -r a97f2023131a -r 0ec8963e088e src/pyams_content/generations/__init__.py --- 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)