def optionalProvidersSource(context):
    # context is result of 'getContent' method of SubscriberForm
    if IGazetteFolder.providedBy(context):
        folder = context
    else:
        folder = IGazetteFolder(context.get('context'), None)

    if folder is not None:
        all_providers = providersVocabularyFactory(context)
        providers = folder.auto_optional_providers
        items = []
        for item in providers:
            try:
                items.append(all_providers.getTerm(item))
            except LookupError:
                pass
        return SimpleVocabulary(items)
    else:
        return SimpleVocabulary([])
 def test_factory(self):
     fti = queryUtility(IDexterityFTI, name='gazette.GazetteFolder')
     factory = fti.factory
     new_object = createObject(factory)
     self.failUnless(IGazetteFolder.providedBy(new_object))
     self.failUnless(ISoupAnnotatable.providedBy(new_object))
 def test_adding(self):
     self.portal.invokeFactory('gazette.GazetteFolder', 'gf1')
     p1 = self.portal['gf1']
     self.failUnless(IGazetteFolder.providedBy(p1))
     self.failUnless(ISoupAnnotatable.providedBy(p1))