class INameTokenTableRowSchema(Interface):
    """Schema for dict rows used in DataGridFields.

    name is the 'real' name
    token is the token used in the vocabularies
    """
    token = schema.TextLine(title=_(u'Token'))
    name = schema.TextLine(title=_(u'Name'))
Example #2
0
class IPythonicTasks(model.Schema):
    """ Marker interface and Dexterity Python Schema for PythonicTasks
    """
    directives.widget(
        'attachments',
        RelatedItemsFieldWidget,
    )
    attachments = RelationList(
        title=_(u'Attachments'),
        value_type=RelationChoice(
            title=_(u'Related'),
            source=CatalogSource(portal_type=['File'], ),
        ),
        required=False,
    )
Example #3
0
    def test_vocabulary(self):
        vocab_name = "example.z3cformwidgets.AvailableThings"
        factory = getUtility(IVocabularyFactory, vocab_name)
        self.assertTrue(IVocabularyFactory.providedBy(factory))

        vocabulary = factory(self.portal)
        self.assertTrue(IVocabularyTokenized.providedBy(vocabulary))
        self.assertEqual(
            vocabulary.getTerm('sony-a7r-iii').title,
            _(u'Sony Aplha 7R III'),
        )
Example #4
0
    def test_vocabulary(self):
        vocab_name = "example.z3cformwidgets.OtherFiles"
        factory = getUtility(IVocabularyFactory, vocab_name)
        self.assertTrue(IVocabularyFactory.providedBy(factory))

        vocabulary = factory(self.portal)
        self.assertTrue(IVocabularyTokenized.providedBy(vocabulary))
        self.assertEqual(
            vocabulary.getTerm('a').title,
            _(u'a'),
        )
    def __call__(self, context):
        # Just an example list of content for our vocabulary,
        # this can be any static or dynamic data, a catalog result for example.
        items = [
            VocabItem(u'sony-a7r-iii', _(u'Sony Aplha 7R III')),
            VocabItem(u'canon-5d-iv', _(u'Canon 5D IV')),
        ]

        # create a list of SimpleTerm items:
        terms = []
        for item in items:
            terms.append(
                SimpleTerm(
                    value=item.token,
                    token=str(item.token),
                    title=item.value,
                )
            )
        # Create a SimpleVocabulary from the terms list and return it:
        return SimpleVocabulary(terms)