"Data 2.1", "Data 2.2" "Data 3.1", "Data 3.2" vocabularytype is the terms portal-type, like SimpleVocabularyTerm which is also the default. It uses column 1 as key=id and column 2 as value=title. If titlerow is True the first line will be skipped. """ if type(csvdata) == type(''): csvdata = StringIO(csvdata) csvreader = csv.reader(csvdata) firstline = True for rec in csvreader: if firstline: firstline = False if titlerow: continue if rec: value=unicode(rec[1], IMPORT_ENCODING) key =rec[0] or make_uuid(value) self.addTerm(key,value,termtype=termtype,silentignore=silentignore) registerType(SimpleVocabulary) registerVocabularyContainer(SimpleVocabulary) # end of class SimpleVocabulary
actTerm = self while actTerm.aq_parent.portal_type != 'TreeVocabulary' \ and hasattr(actTerm.aq_parent, 'getTermKey'): path.append(actTerm.aq_parent.getTermKey()) actTerm = actTerm.aq_parent path.reverse() return path def getVocabularyKey(self): ''' returns the key of the field ''' deprecated("please use the IVocabularyTerm compatible method 'getTermKey'") return self.getTermKey() def getVocabularyValue(self, lang=None, **kwargs): ''' returns the value of the field. The value is a processed value ''' deprecated("please use the IVocabularyTerm compatible method 'getTermValue'") return self.getTermValue(lang=lang, **kwargs) # these should be inherited from SimpleVocabularyTerm processForm = SimpleVocabularyTerm.processForm edit = SimpleVocabularyTerm.edit update = SimpleVocabularyTerm.update registerType(TreeVocabularyTerm, PROJECTNAME) registerVocabularyContainer(TreeVocabularyTerm) registerVocabularyTerm(TreeVocabularyTerm, 'TreeVocabulary') registerVocabularyTerm(TreeVocabularyTerm, 'TreeVocabularyTerm') # end of class TreeVocabularyTerm
Products.Archetypes.utils The instance of the content class is given as parameter. """ target = self.getTarget() return target.getDisplayList(instance) def getVocabularyLines(self, instance=None): """ returns a List of Key-Value tuples """ target = self.getTarget() return target.getVocabularyLines(instance) def getVocabularyDict(self, instance=None): """ returns a vocabulary dictionary as defined in the interface""" target = self.getTarget() return target.getVocabularyDict(instance) def isFlat(self): """ returns true for a flat vocabulary """ target = self.getTarget() return target.isFlat() def showLeafsOnly(self): """ indicates if only leafs should be shown """ target = self.getTarget() return target.showLeafsOnly() registerType(AliasVocabulary) registerVocabularyContainer(AliasVocabulary) # end of class AliasVocabulary