From 32159efdc71d89d591d23d9b93d17e17d29e3f7e Mon Sep 17 00:00:00 2001 From: Steve McMahon Date: Fri, 13 May 2011 14:13:57 -0700 Subject: [PATCH] Vocabulary from parent object --- collective/dexterity_class/container_for_everything.py | 4 ++++ collective/dexterity_class/everything_model.py | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/collective/dexterity_class/container_for_everything.py b/collective/dexterity_class/container_for_everything.py index d93754a..17a801a 100644 --- a/collective/dexterity_class/container_for_everything.py +++ b/collective/dexterity_class/container_for_everything.py @@ -23,6 +23,10 @@ class IContainerforEverything(form.Schema): # and add directives here as necessary. form.model("models/container_for_everything.xml") + + available_fruits = schema.List(title=_(u"Available Fruits"), + default=[], + value_type=schema.TextLine()) # Custom content-type class; objects created for this content type will diff --git a/collective/dexterity_class/everything_model.py b/collective/dexterity_class/everything_model.py index a1cd70e..5ffa03f 100644 --- a/collective/dexterity_class/everything_model.py +++ b/collective/dexterity_class/everything_model.py @@ -19,11 +19,12 @@ from collective.dexterity_class import MessageFactory as _ -fruit_list = [_(u'Apples'), _(u'Oranges'), _(u'Berries'), _(u'Bananas')] -fruits = SimpleVocabulary.fromValues(fruit_list) @grok.provider(schema.interfaces.IContextSourceBinder) def vocabProvider(context): + """ pick up fruit list from parent """ + + fruit_list = getattr(context.__parent__, 'available_fruits', []) return SimpleVocabulary.fromValues(fruit_list) # Interface class; used to define content-type schema.