[Zope3-dev] Schema & Vocabulary Fields

Roché Compaan roche at upfrontsystems.co.za
Wed Sep 10 08:58:10 EDT 2003


* Gary Poster <gary at zope.com> [2003-09-09 23:53]:
> 
> 
> Roché Compaan wrote:
> >Are there any examples that show how to use Vocabulary Fields that
> >return options dynamically. There's a lot of indirection in the code and
> >only examples that show how to use simple vocabularies. It seems that
> >one has to do quite a lot to construct simple lookup widgets - I hope
> >this is not so.
> >
> >I am specifically interested in an example where an object has a
> >reference or references to instances of other objects eg. Product X has
> >Components 1,2 and 3.
> 
> It sounds like what you want is a couple of accessors or a property or 
> some other sort of descriptor.  References don't inherently have 
> anything to do with a vocabulary.

I shouldn't have introduced the term 'references' now although this is
were I am going. On a first pass I only want to define a field on a
class that generates a widget on add/edit forms that provides me with a
selection list that is dynamically populated eg. When I add/edit product
X I am presented with a selection list or a set of checkboxes for the
components that should be enabled on that product. The component options
will most probably be returned by a query.

I thought this is such a common use case that there must be an existing 
field and widget for this and vocabulary field seemed to be it.

> A vocabulary just lets you define the members of the set of possible
> values.

But those members can be dynamic?

> For guidance on how to use vocabularies, though, you won't find much 
> better than the complex sample Fred put in 
> zope/app/browser/form/complexsample.  The vocabulary isn't dynamic, but 
> you can see that a context is passed to it--it could easily use that 
> context to do dynamic things.

Yes, I noticed but based on that example it just seems to much effort to
do a really simple thing. In Formulator this can be done with a
Multi*Widget and a single TALES expression.

-- 
Roché Compaan
Upfront Systems                 http://www.upfrontsystems.co.za



More information about the Zope3-dev mailing list