Mapping source values
=====================

Sometimes a source provides the right choice of objects, but the actual values
we want to talk about are properties or computed views on those objects. The
`mapping proxy source` helps us to map a source to a different value space.

We start out with a source:

  >>> source = [1,2,3,4,5]

and we provide a method that maps the values of the original source to the
values we want to see (we map the numbers to the characters in the english
alphabet):

  >>> map = lambda x: chr(x+96)

Now we can create a mapped source:

  >>> from zc.sourcefactory.mapping import ValueMappingSource
  >>> mapped_source = ValueMappingSource(source, map)
  >>> list(mapped_source)
  ['a', 'b', 'c', 'd', 'e']
  >>> len(mapped_source)
  5
  >>> 'a' in mapped_source
  True
  >>> 1 in mapped_source
  False

You can also use context-dependent sources:

  >>> def bindSource(context):
  ...     return [1,2,3,4,5]
  >>> from zc.sourcefactory.mapping import ValueMappingSourceContextBinder
  >>> binder = ValueMappingSourceContextBinder(bindSource, map)
  >>> bound_source = binder(object())
  >>> list(bound_source)
  ['a', 'b', 'c', 'd', 'e']
  >>> len(bound_source)
  5
  >>> 'a' in bound_source
  True
  >>> 1 in bound_source
  False
