Exemplo n.º 1
0
def upgrade4to5(setupTool):
    _logger.info('Upgrading EDRN Public Portal from profile version 4 to profile version 5')
    portal = _getPortal(setupTool)
    request = portal.REQUEST
    # Whew. Thanks to @davisagli (freakin' brilliant dude) for figuring this out:
    _logger.info("Disabling schema extender's cache")
    from archetypes.schemaextender.extender import disableCache
    disableCache(request)
    # Without the above two lines, we eventually construct an Active ERNE Set during the full ingest below
    # and it mistakenly picks up a Person's schema instead of its own.  When getting its title, a person's
    # is computed, so it looks for a _computeTitle function, but an ActiveERNESet has no such function.
    # Ingest then fails.
    # 
    # Whew!
    # 
    # Now, onward:
    # Disable annoying link integrity checking
    qi = getToolByName(portal, 'portal_quickinstaller')
    propTool = getToolByName(portal, 'portal_properties')
    propTool.site_properties.getProperty('enable_link_integrity_checks', True)
    contentRuleStorage = getUtility(IRuleStorage)
    _logger.info('Disabling link integrity checks')
    propTool.site_properties.manage_changeProperties(enable_link_integrity_checks=False)
    _logger.info('Disabling content rules')
    contentRuleStorage.active = False
    # Clear the catalog
    catalog = getToolByName(portal, 'portal_catalog')
    _logger.info('Clearing the catalog')
    catalog.manage_catalogClear()
    _logger.info('Terminating existing committees with extreme prejudice')
    if 'committees' in portal.keys():
        committees = portal['committees']
        committees.manage_delObjects(committees.keys())
    _logger.info('Enabling JQuery')
    enableJQuery(portal) # Enable jquery.js. Fixes CA-872.
    _logger.info('Disabling Google Analytics')
    removeGoogleAnalytics(portal)
    _logger.info('Clearing the login-lockout table')
    clearLoginLockoutTable(portal) # CA-873
    _logger.info('Installing new packages')
    installNewPackages(portal, _newPackages5)
    _logger.info('Reinstalling products %r', _dependencies5)
    qi.reinstallProducts(_dependencies5)
    for product in _dependencies5:
        _logger.info('Upgrading product "%s"', product)
        qi.upgradeProduct(product)
        transaction.commit()
    if 'specimens' in portal.keys():
        _logger.info('Nuking the specimens tab')
        portal.manage_delObjects('specimens')
    from eke.specimens.upgrades import addSampleSpecimenSets
    # Recreate the members list page to fix the problem with upgrading eea.facetednavigation 4.0rc1→4.5
    _logger.info('Re-creating the members list search page')
    createMembersListSearchPage(portal)
    # Likewise, but for the publications folder: disable and then re-enable faceted view
    if 'publications' in portal.keys():
        publications = portal['publications']
        subtyper = getMultiAdapter((publications, request), name=u'faceted_subtyper')
        _logger.info('Disabling, then re-enabling the faceted subtyper on the publications tab')
        subtyper.disable()
        subtyper.enable()
    _logger.info('Adding sample specimen sets')
    addSampleSpecimenSets(setupTool)
    _logger.info('Disabling portlets on the specimens tab')
    disableSpecimenPortlets(portal)
    _logger.info('Re-setting the auto-ingest paths')
    portal.manage_delProperties(['edrnIngestPaths'])
    setAutoIngestProperties(portal)
    _logger.info('Ingesting everything fully')
    portal.unrestrictedTraverse('@@ingestEverythingFully')()
    _logger.info('Clearing ingest paths to prevent automatic ingest')
    if portal.hasProperty('edrnIngestPaths'):
        portal.manage_delProperties(['edrnIngestPaths'])
    _logger.info('Resetting portal "from" email address')
    portal.manage_changeProperties(email_from_address='*****@*****.**')
    _logger.info('Clearing, finding, and re-building the catalog')
    catalog.clearFindAndRebuild()
    uidCatalog = getToolByName(portal, 'uid_catalog')
    _logger.info('Rebuilding the UID catalog')
    uidCatalog.manage_rebuildCatalog()
    transaction.commit()
Exemplo n.º 2
0
def upgrade1to4(setupTool):
    portal = _getPortal(setupTool)
    
    # Disable annoying link integrity checking
    propTool = getToolByName(portal, 'portal_properties')
    origLinkIntegrityMode = propTool.site_properties.getProperty('enable_link_integrity_checks', True)
    propTool.site_properties.manage_changeProperties(enable_link_integrity_checks=False)
    
    # I do not comprehend why we still have old-style site IDs.  Kill 'em all
    # and let re-ingest bring 'em back
    portal.sites.manage_delObjects(portal.sites.keys())
    
    # Kill the old specimens tab
    if 'specimens' in portal.keys():
        portal.manage_delObjects('specimens')
    
    # Recatalog
    catalog = getToolByName(portal, 'portal_catalog')
    catalog.clearFindAndRebuild()
    
    # Reinstall
    qi = getToolByName(portal, 'portal_quickinstaller')
    qi.reinstallProducts(_dependencies4)
    for product in _dependencies4:
        qi.upgradeProduct(product)
        transaction.commit()
    qi.installProducts(['eea.facetednavigation', 'eke.specimens'])
    installNewPackages(portal, _newPackages4)
    transaction.commit()
 
    # FIXME: OK, the above allegedly did a reinstall of eke.publications which was a profile 0
    # to profile 4. However, tracing through, I found it was already at profile 4! WTF?!
    # Until I can figure that out, I'm manually calling eke.publications's upgrade step:
    from eke.publications.upgrades import setUpFacetedNavigation
    setUpFacetedNavigation(setupTool)
    # Same with specimens:
    from eke.specimens.upgrades import addSampleSpecimenSets, addFacetedSearch, updateDiagnosisIndex
    addSampleSpecimenSets(setupTool)
    addFacetedSearch(setupTool)
    updateDiagnosisIndex(setupTool)
   
    # Remove customizations that made it into software
    nukeCustomizedLoginForm(portal)
    nukeCustomizedCSS(portal)
    nukeCustomizedViews(portal)
    removeExtraViewlets(portal)
    transaction.commit()
    
    # Make sure we're using the Plone 4 editor, TinyMCE, and not the Plone 3 editor, Kupu
    setEditorProperties(portal)
    transaction.commit()
    
    # Recreate faceted pages
    createMembersListSearchPage(portal)
    transaction.commit()
    
    # Create the eke.committees-provided Committees Folder
    createCommitteesFolder(portal)
    transaction.commit()
    
    # Create the new specimens folder
    createSpecimensPage(portal)
    disableSpecimenPortlets(portal)
    resetIngestPaths(portal)
    transaction.commit()
    
    # Update ingest paths, then ingest the committees & specimens folder—and everything else too
    ingestPaths = portal.getProperty('edrnIngestPaths')
    ingestPaths += ('committees', 'specimens')
    portal.manage_changeProperties(edrnIngestPaths=ingestPaths)
    portal.unrestrictedTraverse('@@ingestEverythingFully')()
    transaction.commit()
    
    # Add a container for Collaborative Groups (the QuickLinks portlet already has a link to it)
    # The new committees must already be ingested because the collaborative groups are built
    # from them (from committees whose type == 'Collaborative Group', specifically).
    # Also, we expect Collaborative Groups to upload & download files, so make them versionable.
    createCollaborationsFolder(portal)
    makeFilesVersionable(portal)
    transaction.commit()
    
    # Set up the many_users/many_groups properties
    props = getToolByName(portal, 'portal_properties')
    props.site_properties.manage_changeProperties(many_users=True, many_groups=True)
    transaction.commit()

    # Enable table sorting for everyone
    javascripts = getToolByName(portal, 'portal_javascripts')
    javascripts.getResource('table_sorter.js').setAuthenticated(False)
    javascripts.moveResourceBefore('table_sorter.js', 'dropdown.js')
    addTableSortingNote(portal)
    transaction.commit()

    # Restore annoying link integrity checking
    propTool.site_properties.manage_changeProperties(enable_link_integrity_checks=origLinkIntegrityMode)
    transaction.commit()