DynamicVocabularyCollSeqConverter
=================================

This converter is much like the CollectionSequenceDataConverter except
that it will not return values that aren't part of the widget, instead
of producing LookupError.

This test is a lot like the one for CollectionSequenceDataConverter in
``z3c/form/converter.txt``.

  >>> from zope import component
  >>> from zope import schema
  >>> from zope.schema.vocabulary import SimpleVocabulary
  >>> import z3c.form.widget
  >>> from z3c.form.testing import TestRequest
  >>> from z3c.form import term

  >>> component.provideAdapter(term.CollectionTerms)

On more recent z3c.form versions we need two extra adapters:

  >>> if hasattr(term, 'CollectionTermsVocabulary'):
  ...     # z3c.form 2+
  ...     component.provideAdapter(term.CollectionTermsVocabulary)
  >>> if hasattr(term, 'CollectionTermsSource'):
  ...     # z3c.form 2+
  ...     component.provideAdapter(term.CollectionTermsSource)

  >>> gender = schema.Choice(
  ...     vocabulary = SimpleVocabulary(
  ...         [SimpleVocabulary.createTerm(0, 'f', u'female'),
  ...          SimpleVocabulary.createTerm(1, 'm', u'male')]))

Let's now create a set field and a widget:

  >>> genders = schema.List(value_type=gender)
  >>> seq_widget = z3c.form.widget.SequenceWidget(TestRequest())
  >>> seq_widget.field = genders

We now use the field and widget to instantiate the converter and convert :

  >>> from collective.singing.browser import converters
  >>> converter = converters.DynamicVocabularyCollSeqConverter(
  ...     genders, seq_widget)

We can now convert a real value to a widget value, which will be the term's
token:

  >>> converter.toWidgetValue([0, 1])
  ['f', 'm']

Let's now remove 'm' from the vocabulary and try again:

  >>> gender.vocabulary = SimpleVocabulary(
  ...     [SimpleVocabulary.createTerm(0, 'f', u'female')])
  >>> seq_widget = z3c.form.widget.SequenceWidget(TestRequest())
  >>> seq_widget.field = genders
  >>> converter = converters.DynamicVocabularyCollSeqConverter(
  ...     genders, seq_widget)
  >>> converter.toWidgetValue([0, 1])
  ['f']

This is unlike how the standard CollectionSequenceDataConverter used
to behave, at least up until and including z3c.form 1.9.  In 2.4.3 and
probably earlier a similar improvement has been made.
