def installVocabularies(context): """creates/imports the atvm vocabs.""" if context.readDataFile('eea.mediacentre.txt') is None: return site = context.getSite() atvm = getToolByName(site, 'portal_vocabularies') createSimpleVocabs(atvm, VOCABULARIES)
def install(self): """let's install the countries vocab""" vocabs = {} vocabs['tipo_establecimiento'] = ( ('0001', u'Cadenas'), ('0002', u'Independientes'), ('0003', u'Autoservicios'), ) portal = getToolByName(self,'portal_url').getPortalObject() atvm = getToolByName(portal, ATVOCABULARYTOOL) createSimpleVocabs(atvm, vocabs)
def createTestVocabulary(atvm, testvocabs=None): """creates a simplevocabulary for testing purposes using the utlity methods provided by atvocabularymanager """ portal = api.portal.get() setRoles(portal, TEST_USER_ID, ['Manager']) testvocabs = { 'teststates': (('aut', u'Austria'), ('ger', u'Germany'), ('nor', u'Norway'), ('fin', u'Finland')) } createSimpleVocabs(atvm, testvocabs)
def createTestVocabulary(atvm, testvocabs=None): """creates a simplevocabulary for testing purposes using the utlity methods provided by atvocabularymanager """ portal = api.portal.get() setRoles(portal, TEST_USER_ID, ['Manager']) testvocabs = {'teststates': ( ('aut', u'Austria'), ('ger', u'Germany'), ('nor', u'Norway'), ('fin', u'Finland'))} createSimpleVocabs(atvm, testvocabs)
def _createTestVocabulary(self): """creates a simplevocabulary for testing purposes using the utlity methods provided by atvocabularymanager """ from Products.ATVocabularyManager.utils.vocabs import createSimpleVocabs self.loginAsPortalOwner() testvocabs = {} testvocabs['teststates'] = ( ('aut', u'Austria'), ('ger', u'Germany'), ('nor', u'Norway'), ('fin', u'Finland')) createSimpleVocabs(self.atvm, testvocabs)
def importVocabularies(self): path_tmpl = '../../vocabularies/ddc_%s' site = self.getSite() pvm = getToolByName(site, 'portal_vocabularies') for (filenamepart, vocabname) in (('geo.vdex', 'region_values'), ('geo_bsb.vdex', 'region_values_bsb'), ('sach.vdex', 'topic_values'), ('zeit.vdex', 'epoch_values')): if vocabname not in pvm: pvm.invokeFactory('VdexFileVocabulary', vocabname) pvm[vocabname].importXMLBinding( pkg_resources.resource_string( __name__, path_tmpl % filenamepart)) pvm[vocabname].showLeafsOnly = False for vocab_name, vocabulary in constants.vocabularies.items(): if not hasattr(pvm, vocab_name): createSimpleVocabs(pvm, {vocab_name: vocabulary.items()})
def importVocabularies(self): if self.readDataFile('philrom.policy_marker.txt') is None: return path_tmpl = '../../../vocabularies/%s' site = self.getSite() pvm = getToolByName(site, 'portal_vocabularies') for (filenamepart, vocabname) in ( ('area.vdex', 'region_values'), ('periodo.vdex', 'epoch_values'), ('temi.vdex', 'topic_values'), ): if vocabname in pvm: pvm.manage_delObjects([vocabname]) pvm.invokeFactory('VdexFileVocabulary', vocabname, showLeafsOnly=False) pvm[vocabname].importXMLBinding(pkg_resources.resource_string( __name__, path_tmpl % filenamepart)) for simple_vocabname in vocabularies: if simple_vocabname in pvm: pvm.manage_delObjects([simple_vocabname]) createSimpleVocabs( pvm, {simple_vocabname: vocabularies[simple_vocabname].items()})
def installVocabularies(context): """creates/imports the atvm vocabs.""" if context.readDataFile('eea.reports.txt') is None: return site = context.getSite() atvm = getToolByName(site, 'portal_vocabularies') # Cleanup broken vocabularies for name in VOCABULARIES: voc = getattr(atvm, name, None) if not voc: continue if isinstance(voc, SimpleVocabulary): continue logger.info("Deleting old broken portal_vocabularies/%s", name) voc.manage_delObjects(voc.objectIds()) atvm.manage_delObjects([name, ]) # Adding vocabularies createSimpleVocabs(atvm, VOCABULARIES)
def evolve(context): """creates/imports the atvm vocabs.""" site = getSite() atvm = getToolByName(site, 'portal_vocabularies') createSimpleVocabs(atvm, VOCABULARIES)
def installVocabularies(context): """ Creates/imports the atvm vocabs. """ # only run this step if we are in eea.dataservice profile if context.readDataFile('eea.dataservice.txt') is None: return site = context.getSite() atvm = getToolByName(site, ATVOCABULARYTOOL) # Creat countries vocabulary if COUNTRIES_DICTIONARY_ID not in atvm.contentIds(): hierarchicalVocab = {} hierarchicalVocab[(COUNTRIES_DICTIONARY_ID, 'European Countries')] = {} createHierarchicalVocabs(atvm, hierarchicalVocab) countries = getCountriesDictionary() for term in countries: vocab = atvm[COUNTRIES_DICTIONARY_ID] vocab.invokeFactory('TreeVocabularyTerm', term[0], title=term[1]) for subterm in countries[term].keys(): subvocab = vocab[term[0]] subvocab.invokeFactory('TreeVocabularyTerm', subterm[0], title=subterm[1]) subvocab.reindexObject() vocab.reindexObject() else: logger.warn('eea.dataservice countries vocabulary already exist.') # Create reference vocabulary if REFERENCE_DICTIONARY_ID not in atvm.contentIds(): createSimpleVocabs(atvm, REFERENCE_DICTIONARY) atvm[REFERENCE_DICTIONARY_ID].setTitle('Coordinate reference system') else: logger.warn('eea.dataservice reference vocabulary already exist.') # Create quality vocabulary if QUALITY_DICTIONARY_ID not in atvm.contentIds(): createSimpleVocabs(atvm, QUALITY_DICTIONARY) atvm[QUALITY_DICTIONARY_ID].setTitle('Geographic information quality') else: logger.warn('eea.dataservice quality vocabulary already exist.') # Create quick link vocabulary for datasets if QLD_DICTIONARY_ID not in atvm.contentIds(): createSimpleVocabs(atvm, QLD_DICTIONARY) atvm[QLD_DICTIONARY_ID].setTitle('Datasets quick links') else: logger.warn('eea.dataservice quick link vocabulary for datasets ' 'already exist.') # Create quick link vocabulary for maps and graphs if QLMG_DICTIONARY_ID not in atvm.contentIds(): createSimpleVocabs(atvm, QLMG_DICTIONARY) atvm[QLMG_DICTIONARY_ID].setTitle('Maps & graphs quick links') else: logger.warn('eea.dataservice quick link vocabulary for maps and graphs ' 'already exist.') # Create categories vocabulary if CATEGORIES_DICTIONARY_ID not in atvm.contentIds(): createSimpleVocabs(atvm, CATEGORIES_DICTIONARY) atvm[CATEGORIES_DICTIONARY_ID].setTitle('Dataservice categories') else: logger.warn('eea.dataservice categories vocabulary already exist.') # Create conversions vocabulary convertion_fresh_install = False if CONVERSIONS_DICTIONARY_ID not in atvm.contentIds(): convertion_fresh_install = True createSimpleVocabs(atvm, CONVERSIONS_DICTIONARY) atvm[CONVERSIONS_DICTIONARY_ID].setTitle( 'Conversion format for dataservice') else: logger.warn('eea.dataservice conversion vocabulary already exist.') # Set public the vocabulary items we use for active convertion if convertion_fresh_install: for vocabId in CONVERSIONS_USED: wftool = getToolByName(site, 'portal_workflow') vocabParentOb = getattr(atvm, CONVERSIONS_DICTIONARY_ID) vocabItem = getattr(vocabParentOb, vocabId) state = wftool.getInfoFor(vocabItem, 'review_state', '(Unknown)') if state == 'published': continue try: wftool.doActionFor(vocabItem, 'publish', comment='Auto published by migration script.') except Exception: logger.debug("eea dataservice setuphandlers migration script " "couldn't auto publish")