[z3-five] Using vocabularies for Choice fields where the vocabulary is acquired

Martin Aspeli optilude at gmx.net
Wed Dec 27 18:11:54 CET 2006


Hi,

I want to use a vocabulary in a zope.schema.Choice field in a formlib 
form. From Philipp's book, I see how to hook a vocabulary up to a form, 
but this either uses hard coded simple items or the utility registry (a 
utility vocabulary).

I need to present a list of portal types, acquired by traversing to the 
portal_types tool and asking it for a list of type ids (or id/name 
combinations, probably).

To do so, however, I need a context so that I can acquire the 
portal_types tool. Both a module-level vocabulary and a utility 
vocabulary suffers from being context-less. However, at least at the 
time when the form is rendered I will have a context.

Can anyone point me to some code or documentation that shows how to wait 
until run-time to define the vocabulary, and gives me the current 
context from which to do so?

Thanks,
Martin



More information about the z3-five mailing list