def __init__(self, portal, migrator, src_portal_type=None, dst_portal_type=None, **kwargs): self.portal = portal self.catalog = getToolByName(portal, 'portal_catalog') self.migrator = migrator if src_portal_type is None: self.src_portal_type = self.migrator.src_portal_type else: self.src_portal_type = src_portal_type if dst_portal_type is None: self.dst_portal_type = self.migrator.dst_portal_type else: self.dst_portal_type = dst_portal_type self.src_meta_type = self.migrator.src_meta_type self.dst_meta_type = self.migrator.dst_meta_type self.transaction_size = int(kwargs.get('transaction_size', 20)) self.full_transaction = kwargs.get('full_transaction', False) self.use_savepoint = kwargs.get('use_savepoint', False) if self.full_transaction and self.use_savepoint: raise ValueError self.out = StringIO() self.counter = 0 self.errors = [] # Disable schema cache request = getattr(portal, 'REQUEST', None) if request is not None: disableCache(request)
def markNewContentObject(obj, event): """Mark newly created content as Pigeonhole-aware if its portal type is in our list of Aware types""" # get our local utility # this is incidentally also our lame check # to see if PH is installed here try: utility = getUtility(IPigeonholizer) except ComponentLookupError: # ignore problems when we can't find the utility -- PH might not # be installed utility = None if utility is not None: if obj.portal_type in utility.ph_aware_types: alsoProvides(obj, IPigeonholeAware) elif blobsAvailable: # in Plone 3, the meta_type for blob-based Images and Files # is just ATBlob, but thanks to a custom factory, they DO have # marker interfaces set. Check them! if "Image" in utility.ph_aware_types and \ IATBlobImage.providedBy(obj): alsoProvides(obj, IPigeonholeAware) elif "File" in utility.ph_aware_types and \ IATBlobFile.providedBy(obj): alsoProvides(obj, IPigeonholeAware) if disableCache is not None: disableCache(getSite().REQUEST)
def upgrade12to13(setupTool): _logger.info('Upgrading EDRN Public Portal from profile version 12 to profile version 13') portal = _getPortal(setupTool) request = portal.REQUEST catalog, setup = getToolByName(portal, 'portal_catalog'), getToolByName(portal, 'portal_setup') _logger.info("Disabling schema extender's cache") from archetypes.schemaextender.extender import disableCache disableCache(request) 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 qi = getToolByName(portal, 'portal_quickinstaller') qi.upgradeProduct('eke.ecas') _logger.info('Ingesting everything fully') setAutoIngestProperties(portal) 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() _logger.info('Upgrade 12-to-13 complete')
def upgrade10to11(setupTool): _logger.info('Upgrading EDRN Public Portal from profile version 10 to profile version 11 with nifty visualizations') portal = _getPortal(setupTool) request = portal.REQUEST catalog, setup = getToolByName(portal, 'portal_catalog'), getToolByName(portal, 'portal_setup') _logger.info("Disabling schema extender's cache") from archetypes.schemaextender.extender import disableCache disableCache(request) 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 # Set new summarizer data sources _logger.info('Setting up new summary data sources') import socket if not socket.gethostname().startswith('tumor'): biomarkerSummary = 'https://edrn.jpl.nasa.gov/cancerdataexpo/summarizer-data/biomarker/@@summary' siteSummary = 'https://edrn.jpl.nasa.gov/cancerdataexpo/summarizer-data/collaboration/@@summary' pubSummary = 'https://edrn.jpl.nasa.gov/cancerdataexpo/summarizer-data/publication/@@summary' else: biomarkerSummary = 'https://edrn-dev.jpl.nasa.gov/cancerdataexpo/summarizer-data/biomarker/@@summary' siteSummary = 'https://edrn-dev.jpl.nasa.gov/cancerdataexpo/summarizer-data/collaboration/@@summary' pubSummary = 'https://edrn-dev.jpl.nasa.gov/cancerdataexpo/summarizer-data/publication/@@summary' if 'biomarkers' in portal.keys(): _logger.info('Setting biomarkers summary data source to %s', biomarkerSummary) o = portal['biomarkers'] o.bmSumDataSource = biomarkerSummary if 'committees' in portal.keys(): _logger.info('Setting committees summary data source to %s', siteSummary) o = portal['committees'] o.siteSumDataSource = siteSummary if 'publications' in portal.keys(): _logger.info('Setting publications summary data source to %s', pubSummary) o = portal['publications'] o.pubSumDataSource = pubSummary _logger.info('Ingesting everything fully') setAutoIngestProperties(portal) 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() _logger.info('Upgrade 10-to-11 complete')
def upgrade9to10(setupTool): _logger.info('Upgrading EDRN Public Portal from profile version 9 to profile version 10') portal = _getPortal(setupTool) request = portal.REQUEST catalog, setup = getToolByName(portal, 'portal_catalog'), getToolByName(portal, 'portal_setup') _logger.info("Disabling schema extender's cache") from archetypes.schemaextender.extender import disableCache disableCache(request) 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 # No, decided not to write secretome with Plone: # qi.installProduct('eke.secretome') # setup.runAllImportStepsFromProfile('profile-eke.secretome:default') disablePublicationsPortlets(portal) # Set the new bmuDataSource on biomarkers, but not on testing (this is ugly) if 'biomarkers' in portal.keys(): import socket if not socket.gethostname().startswith('tumor'): b = portal['biomarkers'] b.bmuDataSource = 'http://edrn.jpl.nasa.gov/cancerdataexpo/rdf-data/biomuta/@@rdf' _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() _logger.info('Upgrade 9-to-10 complete')
def __init__(self, portal, migrator, src_portal_type=None, dst_portal_type=None, **kwargs): self.portal = portal self.catalog = getToolByName(portal, 'portal_catalog') self.migrator = migrator if src_portal_type is None: self.src_portal_type = self.migrator.src_portal_type else: self.src_portal_type = src_portal_type if dst_portal_type is None: self.dst_portal_type = self.migrator.dst_portal_type else: self.dst_portal_type = dst_portal_type self.src_meta_type = self.migrator.src_meta_type self.dst_meta_type = self.migrator.dst_meta_type self.transaction_size = int(kwargs.get('transaction_size', 20)) self.full_transaction = kwargs.get('full_transaction', False) self.use_savepoint = kwargs.get('use_savepoint', False) self.limit = kwargs.get('limit', False) if self.full_transaction and self.use_savepoint: raise ValueError self.out = StringIO() self.counter = 0 self.errors = [] # Disable schema cache request = getattr(portal, 'REQUEST', None) if request is not None: disableCache(request)
def addSubmission(self, REQUEST, folder, portal_type): """ Perform content operations as the appropriate user. """ form = aq_parent(aq_inner(self)) if folder is None: folder = self order = folder.getOrdering() if not hasattr(order, '__contains__'): order = folder.contentIds() title_field_name = self.getTitleField() or 'title' changed = {} if title_field_name in form: # Get the title from a form field in the submission title_field = form[title_field_name] title, kwargs = title_field.fgField.widget.process_form( title_field, title_field.fgField, REQUEST.form) changed[title_field_name] = title else: # Generate a title from the form title title = '{0} Submission'.format(form.Title()) # Generate an id from the title, adding a suffix if existing id_ = str(norm_ifaces.IUserPreferredURLNormalizer( REQUEST).normalize(title)) if id_ in order: # Exising objects have the id, find the next index suffix order_idx = len(folder) - 1 base_id = id_ idx = 0 while id_ in order: while order_idx >= 0: # Start at the end to try and find the highest index order_id = order[order_idx] if order_id.startswith(base_id + '-'): idx = int(order_id[len(base_id + '-'):]) break order_idx -= 1 id_ = '{0}-{1}'.format(base_id, (idx + 1)) new_id = folder.invokeFactory(portal_type, id_, title=title) submission = folder[new_id] submission.addReference(self, relationship='submissionFolderAdapter') # Mark the item as a form submission so the schema is extended with the # form schema interface.alsoProvides(submission, IFormSubmission) # Set the submission field values now that the extender applies extender.disableCache(REQUEST) schema = submission.Schema() for field in schema.fields(): if field.__name__ in ('id', 'title'): # skip factory arguments continue result = field.widget.process_form( submission, field, REQUEST.form, empty_marker=BaseObject._marker, validating=False) if result is BaseObject._marker or result is None: continue changed[field.__name__] = result[0] if field.__name__ in ('id', 'title'): # already set in the factory continue field.set(submission, result[0], **result[1]) # Apply workflow transitions workflow = getToolByName(submission, 'portal_workflow') for transition in self.getSubmissionTransitions(): try: workflow.doActionFor(submission, transition) except WorkflowCore.WorkflowException: logger.exception( 'Workflow transition {0!r} failed on form submission: {1}' .format(transition, self.absolute_url)) submission.setLayout('base_view') return submission, changed
def upgrade6to7(setupTool): _logger.info('Upgrading EDRN Public Portal from profile version 6 to profile version 7') portal = _getPortal(setupTool) request = portal.REQUEST # _logger.info('Fixing login lockout plugin') # fixLoginLockoutPlugin(portal) _logger.info("Disabling schema extender's cache") from archetypes.schemaextender.extender import disableCache disableCache(request) 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 # _logger.info('Reloading Javascript Registry') # setupTool.runImportStepFromProfile(PROFILE_ID, 'jsregistry') # Clear the catalog catalog = getToolByName(portal, 'portal_catalog') _logger.info('Clearing the catalog') catalog.manage_catalogClear() _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, _newPackages7) _logger.info('Reinstalling products %r', _dependencies7) qi.reinstallProducts(_dependencies7) for product in _dependencies7: _logger.info('Upgrading product "%s"', product) qi.upgradeProduct(product) transaction.commit() for thing in _reinstall7: _logger.info('Uninstalling then reinstalling "%s"' % thing) qi.uninstallProducts([thing]) qi.installProduct(thing) # edrnThemeUpgrade4to5(setupTool) # ekeCommitteesReloadTypes4to5(setupTool) # ekeSpecimensSetupCatalog(setupTool) # 2013-10-08: no longer needed, ops BMDB is fine: # _logger.info('Setting biomarkers to ingest from TEST BMDB') #setBiomarkerIngestPaths(portal, 'http://tumor.jpl.nasa.gov/bmdb/rdf/biomarkers', # 'http://tumor.jpl.nasa.gov/bmdb/rdf/biomarkerorgans') # 2013-10-08: we will have to re-do this after Portal 4.2 is finally deployed at NCI: removeCustomQuickLinksPortlet(portal) loadPortalTypes(setupTool) upgradeBiomarkerFolders(setupTool) # /2013-10-08 _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()
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()