def upgrade(self, root): installed_ids = root.objectIds() # Remove old services for to_remove in ['globals', 'service_groups', 'service_static_cache_manager', 'service_kupu', 'service_kupu_silva', 'service_renderer_registry', 'service_sidebar', 'service_typo_chars', 'service_view_registry', 'service_views', 'service_resources', 'service_views', 'service_toc_filter']: if to_remove in installed_ids: root.manage_delObjects([to_remove]) # Reset SMI skin, add service_ui if root._smi_skin != SMI_SKIN: root._smi_skin = SMI_SKIN if 'service_ui' not in installed_ids: factory = root.manage_addProduct['silva.ui'] factory.manage_addUIService() # Update catalog indexes catalog = root.service_catalog if 'version_status' in catalog.indexes(): catalog.delIndex('version_status') catalog.addIndex('publication_status', 'FieldIndex') # Add service filtering if 'service_filtering' not in installed_ids: factory = root.manage_addProduct['Silva'] factory.manage_addFilteringService() # If silva.app.redirectlink we disable it (for the document # conversion). It can be re-enabled later on. extensions = root.service_extensions if extensions.is_installed('silva.app.redirectlink'): extensions.uninstall('silva.app.redirectlink') # Update catalog indexes catalog = root.service_catalog if 'content_intid' not in catalog.schema(): catalog.addColumn('content_intid') for column in ['sidebar_position', 'sidebar_title', 'location', 'start_datetime', 'end_datetime']: if column in catalog.schema(): catalog.delColumn(column) for index in ['start_datetime', 'end_datetime', 'sidebar_parent', 'haunted_path']: if index in catalog.indexes(): catalog.delIndex(index) configure_metadata(root.service_metadata, None) return root
def upgrade(self, root): # Register service_files and others sm = root.getSiteManager() sm.registerUtility(root.service_files, IFilesService) if hasattr(aq_base(root), 'service_codesources'): # We should have it however ... sm.registerUtility( root.service_codesources, ICodeSourceService) # Register service extensions. sm.registerUtility(root.service_extensions, IExtensionService) # Update metadata service metadata = root.service_metadata sm.registerUtility(metadata, IMetadataService) # Update the catalog setup_intid(root) catalog = root.service_catalog catalog.__class__ = CatalogService sm.registerUtility(catalog, ICatalogService) indexes = catalog._catalog.indexes for key, index in indexes.items(): if index.__class__.__name__ == 'ProxyIndex': del indexes[key] catalog._catalog.indexes = indexes # We reinitialize the metadata sets to recreate indexes for mset in metadata.collection.objectValues(): for melt in mset.objectValues(): if ('doc_attr' in melt.index_constructor_args and melt.index_constructor_args['doc_attr'] == 'proxy_value'): del melt.index_constructor_args['doc_attr'] if melt.index_type == 'TextIndex': melt.index_type = 'ZCTextIndex' melt.index_constructor_args.update( {'index_type': 'Cosine Measure', 'lexicon_id': 'silva_lexicon'}) mset.initialized = 0 mset.initialize() if hasattr(aq_base(root), 'service_annotations'): root.manage_delObjects(['service_annotations']) # Be sure the metadata are configured to be able to install the missing products. configure_metadata(root.service_metadata, None) # Setup the cs_toc and cs_citation CS's. service_ext = root.service_extensions if not service_ext.is_installed('SilvaExternalSources'): service_ext.install('SilvaExternalSources') else: service_ext.refresh('SilvaExternalSources') if root._getOb('cs_toc', None) is None: toc = root.service_codesources.get_installable_source( 'cs_toc') toc.install(root) if root._getOb('cs_citation', None) is None: cit = root.service_codesources.get_installable_source( 'cs_citation') cit.install(root) return root