Exemple #1
0
def setupVocabs(portal, logger):
    #
    # ATVocabManager setup
    #
    logger.info("Starting ATVocabManager configuration ")
    atvm = getToolByName(portal, ATVOCABULARYTOOL)
    wftool = getToolByName(portal, "portal_workflow")

    for vkey in vocabs.keys():
        # create vocabulary if it doesnt exist:
        vocabname = vkey
        if not atvm.getVocabularyByName(vocabname):
            _createObjectByType("SimpleVocabulary", atvm, vocabname)
            logger.debug("adding vocabulary %s" % vocabname)

        vocab = atvm[vocabname]

        # delete the 'default' item
        if hasattr(vocab, "default"):
            vocab.manage_delObjects(["default"])

        for (ikey, value) in vocabs[vkey]:
            if not hasattr(vocab, ikey):
                _createObjectByType("SimpleVocabularyTerm", vocab, ikey)
                logger.debug("adding vocabulary item %s %s" % (ikey, value))
                vocab[ikey].setTitle(value)

        # reindex
        vocab.reindexObject()
Exemple #2
0
def uninstallVocabs(portal, logger):
    #
    # ATVocabManager setup
    #
    logger.info("Reverting ATVocabManager configuration ")
    atvm = getToolByName(portal, ATVOCABULARYTOOL)

    for vkey in vocabs.keys():
        vocabname = vkey
        if atvm.getVocabularyByName(vocabname):
            atvm._delObject(vocabname)
            logger.debug("removing vocabulary %s" % vocabname)