src/pyams_content/generations/__init__.py
changeset 1208 0ec8963e088e
parent 1196 8e8f528f8d3b
child 1238 6c23614804f2
equal deleted inserted replaced
1207:a97f2023131a 1208:0ec8963e088e
    11 #
    11 #
    12 
    12 
    13 __docformat__ = 'restructuredtext'
    13 __docformat__ = 'restructuredtext'
    14 
    14 
    15 import logging
    15 import logging
    16 logger = logging.getLogger("PyAMS (content)")
    16 from importlib import import_module
    17 
    17 
    18 from hypatia.text.lexicon import Lexicon
    18 from hypatia.text.lexicon import Lexicon
    19 from pyramid.path import DottedNameResolver
    19 from pyramid.path import DottedNameResolver
       
    20 from zope.dublincore.interfaces import IZopeDublinCore
    20 from zope.lifecycleevent import ObjectCreatedEvent
    21 from zope.lifecycleevent import ObjectCreatedEvent
    21 from zope.dublincore.interfaces import IZopeDublinCore
    22 
    22 
    23 from pyams_catalog.index import DatetimeIndexWithInterface, FieldIndexWithInterface, KeywordIndexWithInterface
    23 from pyams_catalog.index import FieldIndexWithInterface, KeywordIndexWithInterface, DatetimeIndexWithInterface
    24 from pyams_catalog.interfaces import DATE_RESOLUTION, MINUTE_RESOLUTION
    24 from pyams_catalog.nltk import NltkFullTextProcessor
    25 from pyams_catalog.nltk import NltkFullTextProcessor
    25 from pyams_catalog.site import check_required_indexes
    26 from pyams_catalog.site import check_required_indexes
    26 from pyams_catalog.interfaces import MINUTE_RESOLUTION, DATE_RESOLUTION
    27 from pyams_content.component.theme import ICollectionsInfo, ITagsInfo, IThemesInfo
    27 from pyams_content.component.theme import ITagsInfo, IThemesInfo, ICollectionsInfo
    28 from pyams_content.interfaces import CONTRIBUTOR_ROLE, IBaseContent, MANAGER_ROLE, OWNER_ROLE, PILOT_ROLE, \
    28 from pyams_content.interfaces import IBaseContent, WEBMASTER_ROLE, OWNER_ROLE, PILOT_ROLE, MANAGER_ROLE, \
    29     WEBMASTER_ROLE
    29     CONTRIBUTOR_ROLE
       
    30 from pyams_content.reference import ReferencesManager
    30 from pyams_content.reference import ReferencesManager
    31 from pyams_content.reference.pictograms import PictogramTable
    31 from pyams_content.reference.pictograms import PictogramTable
    32 from pyams_content.root.interfaces import ISiteRootToolsConfiguration
    32 from pyams_content.root.interfaces import ISiteRootToolsConfiguration
    33 from pyams_content.shared.common.manager import SharedToolContainer
       
    34 from pyams_content.shared.common.interfaces import IWfSharedContent
    33 from pyams_content.shared.common.interfaces import IWfSharedContent
    35 from pyams_content.shared.common.interfaces.types import IWfTypedSharedContent
    34 from pyams_content.shared.common.interfaces.types import IWfTypedSharedContent
       
    35 from pyams_content.shared.common.manager import SharedToolContainer
    36 from pyams_content.shared.form.interfaces import IFormsManagerFactory
    36 from pyams_content.shared.form.interfaces import IFormsManagerFactory
    37 from pyams_content.shared.imagemap.interfaces import IImageMapManagerFactory
    37 from pyams_content.shared.imagemap.interfaces import IImageMapManagerFactory
    38 from pyams_content.shared.logo.interfaces import ILogosManagerFactory
    38 from pyams_content.shared.logo.interfaces import ILogosManagerFactory
    39 from pyams_content.shared.news.interfaces import INewsManagerFactory
    39 from pyams_content.shared.news.interfaces import INewsManagerFactory
    40 from pyams_content.shared.resource.interfaces import IResourceManagerFactory
    40 from pyams_content.shared.resource.interfaces import IResourceManagerFactory
    43 from pyams_i18n.index import I18nTextIndexWithInterface
    43 from pyams_i18n.index import I18nTextIndexWithInterface
    44 from pyams_security.index import PrincipalsRoleIndex
    44 from pyams_security.index import PrincipalsRoleIndex
    45 from pyams_thesaurus.index import ThesaurusTermsListFieldIndex
    45 from pyams_thesaurus.index import ThesaurusTermsListFieldIndex
    46 from pyams_utils.interfaces.site import ISiteGenerations
    46 from pyams_utils.interfaces.site import ISiteGenerations
    47 from pyams_utils.interfaces.traversing import IPathElements
    47 from pyams_utils.interfaces.traversing import IPathElements
    48 from pyams_utils.registry import utility_config, get_global_registry
    48 from pyams_utils.registry import get_global_registry, utility_config
    49 from pyams_utils.site import check_required_utilities
    49 from pyams_utils.site import check_required_utilities
    50 from pyams_workflow.interfaces import IWorkflowState, IWorkflowPublicationInfo
    50 from pyams_workflow.interfaces import IWorkflowPublicationInfo, IWorkflowState
       
    51 
       
    52 
       
    53 logger = logging.getLogger("PyAMS (content)")
    51 
    54 
    52 
    55 
    53 def get_fulltext_lexicon(language):
    56 def get_fulltext_lexicon(language):
    54     return Lexicon(NltkFullTextProcessor(language=language))
    57     return Lexicon(NltkFullTextProcessor(language=language))
    55 
    58 
   322 @utility_config(name='PyAMS content', provides=ISiteGenerations)
   325 @utility_config(name='PyAMS content', provides=ISiteGenerations)
   323 class WebsiteGenerationsChecker(object):
   326 class WebsiteGenerationsChecker(object):
   324     """PyAMS content package generations checker"""
   327     """PyAMS content package generations checker"""
   325 
   328 
   326     order = 100
   329     order = 100
   327     generation = 1
   330     generation = 2
   328 
   331 
   329     @staticmethod
   332     def evolve(self, site, current=None):
   330     def evolve(site, current=None):
       
   331         """Check for required utilities, tables and tools"""
   333         """Check for required utilities, tables and tools"""
   332         check_required_utilities(site, REQUIRED_UTILITIES)
   334         check_required_utilities(site, REQUIRED_UTILITIES)
   333         check_required_indexes(site, get_required_indexes())
   335         check_required_indexes(site, get_required_indexes())
   334         check_required_tables(site, REQUIRED_TABLES)
   336         check_required_tables(site, REQUIRED_TABLES)
   335         check_required_tools(site, ISiteRootToolsConfiguration, REQUIRED_TOOLS)
   337         check_required_tools(site, ISiteRootToolsConfiguration, REQUIRED_TOOLS)
       
   338 
       
   339         if not current:
       
   340             current = 1
       
   341         for generation in range(current, self.generation):
       
   342             module_name = 'pyams_content.generations.evolve{}'.format(generation)
       
   343             module = import_module(module_name)
       
   344             module.evolve(site)