[Zope3-dev] Re: ChoiceField and the use of sources/vocabularies

Philipp von Weitershausen philipp at weitershausen.de
Mon Oct 1 15:41:36 EDT 2007


Christian Theune wrote:
> Zagy and I are trying to make z3c.form compatible with sources.

Shrug... Why wouldn't it be compatible already? Shouldn't the widget 
abstract everything away?

> We had to investigate zope.schema for that and found the mess of vocabularies
> and sources that is still around. 
> 
> Here are some facts we found:
> 
> - The Choice field has an attribute `vocabulary` which it says to be an
>   'IBaseVocabulary' object.
> 
> - Reading the code of the choice field turns out that the actual
>   contract is an 'ISource'.
> 
> - Most client code working against the `vocabulary` attribute actually
>   assumes it to be an IIterableVocabulary.

That should be fixed then. Adaption to some iteration interface seems 
sensible.

> - The vocabulary code is badly entangled and mixes up concepts that
>   sources get right.
> 
> - Widgets for the choice field have to react differently to sources and
>   vocabularies.
> 
> We think:
> 
> - The contract for the `vocabulary` attribute should be ISource.

+1

Making a contract more loose than it already is is always possible.

> - Client code (e.g. a widget) should adapt the generic source it gets to
>   a more specific and richer interface like IIterableSource.
> 
> - Widgets for the choice field shouldn't have to care for two different
>   things that the source could be.
> 
> - Vocabularies ought to die. 

No can do. But perhaps we can keep the amount of BBB dance as small as 
possible. Vocabularies are just special ISource implementations. They 
should work, even if they mix stuff. Mixing stuff isn't forbidden...

> We'd love to remove all traces of vocabularies from zope.schema and it
> more clear how to use sources.

+1 to making sources more straightforward.

> As deprecation has fallen out of favor, we wonder how to get rid of
> vocabularies. We definitely do not want to fork zope.schema. Would a
> sufficiently newer version (3.5, 4?) rectify breaking something in this
> way?
> 
> I estimate that providing BBB is going to be a real pain. :/

So pain it is...


-- 
http://worldcookery.com -- Professional Zope documentation and training


More information about the Zope3-dev mailing list