Dynamic vocabulary for an Archetypes field

I keep forgetting how to do dynamic vocabularies for an AT field. As explained in the Vocabulary() method in Field.py, this method will return either the list defined in the vocabulary parameter of the field, or, among others, the list resulting from calling the method defined in the string given as value to the vocabulary parameter.

The code below will make the explanation easier to understand:

... 
    LinesField(
        name='domains',
        vocabulary='getVocabularyForDomains' )
...
    def getVocabularyForDomains(self):
        return ['first', 'second', 'third', 'etc']

Comments