[Grok-dev] Values from another document before rendering
Adam Summers
adamsummers1 at me.com
Fri Jan 7 21:23:16 EST 2011
Hi Group,
I'm using grok 1.2.1, and I have a problem calling a vocab in an addform:
My vocabulary is as follows:
class AccountMasterVocabularies(grok.GlobalUtility):
grok.implements(schema.interfaces.IVocabularyFactory)
grok.name('accnt')
def __call__(self, context):
return(schema.vocabulary.SimpleVocabulary([
schema.vocabulary.SimpleTerm('01', 'term 1', u'Really'),
schema.vocabulary.SimpleTerm('02', 'term 2', u'Truly') ]))
(So I would expect the vocab to be registered as 'accnt', no?)
Then I have an Schema/Model as follows:
class IGLLine(interface.Interface):
"""A Line"""
account = schema.Choice(title=u"Account", vocabulary='accnt')
class GLLine(grok.Model):
"""The implementation of the GLLine"""
grok.context(GLLineContainer)
grok.implements(IGLLine)
account = None
However, I get a VocabularyRegistryError because the vocabulary is unknown (see below). What am I missing????
Thanks in advance,
Adam
File '/Users/adamsummers1/.buildout/eggs/grok-1.2.1-py2.6.egg/grok/publication.py', line 90 in callObject
return super(ZopePublicationSansProxy, self).callObject(request, ob)
File '/Users/adamsummers1/.buildout/eggs/zope.app.publication-3.12.0-py2.6.egg/zope/app/publication/zopepublication.py', line 207 in callObject
return mapply(ob, request.getPositionalArguments(), request)
<groktwotwo.app.GLLineAddForm object at 0x303d610>
File '/Users/adamsummers1/.buildout/eggs/zope.publisher-3.12.4-py2.6.egg/zope/publisher/publish.py', line 107 in mapply
return debug_call(obj, args)
File '/Users/adamsummers1/.buildout/eggs/zope.publisher-3.12.4-py2.6.egg/zope/publisher/publish.py', line 113 in debug_call
return obj(*args)
File '/Users/adamsummers1/.buildout/eggs/grokcore.formlib-1.6-py2.6.egg/grokcore/formlib/components.py', line 90 in __call__
self.update_form()
File '/Users/adamsummers1/.buildout/eggs/grokcore.formlib-1.6-py2.6.egg/grokcore/formlib/components.py', line 62 in update_form
super(GrokForm, self).update()
File '/Users/adamsummers1/.buildout/eggs/zope.formlib-4.0.5-py2.6.egg/zope/formlib/form.py', line 758 in update
self.setUpWidgets()
File '/Users/adamsummers1/.buildout/eggs/zope.formlib-4.0.5-py2.6.egg/zope/formlib/form.py', line 739 in setUpWidgets
form=self, adapters=self.adapters, ignore_request=ignore_request)
File '/Users/adamsummers1/.buildout/eggs/zope.formlib-4.0.5-py2.6.egg/zope/formlib/form.py', line 266 in setUpWidgets
field = field.bind(context)
File '/Users/adamsummers1/.buildout/eggs/zope.schema-3.7.0-py2.6.egg/zope/schema/_field.py', line 291 in bind
clone.vocabulary = vr.get(object, self.vocabularyName)
File '/Users/adamsummers1/.buildout/eggs/zope.schema-3.7.0-py2.6.egg/zope/schema/vocabulary.py', line 166 in get
raise VocabularyRegistryError(name)
VocabularyRegistryError: unknown vocabulary: 'accnt'
On 27 Nov 2009, at 4:48 PM, Kathy Manwaring wrote:
> Hi Sebastian,
>
> Thank you so much for such a quick response and for including an actual
> code example!
>
> I am on a 3 day conference at the moment, but will try this out as soon as
> I can next week.
>
> Kathy
>
> Sebastian Ware wrote:
>> This is what I do. I have a field defined in an interface:
>>
>> gallery_id = schema.Choice(title=u"Gallery", vocabulary=u"Published
> NewProductGalleries")
>>
>> The vocabulary looks like this (it is a bit dirty, but it might help you
> in the right direction):
>>
More information about the Grok-dev
mailing list