Registry
========

We use a simple registry for the pluggable policies that we
provide. This registry is basically a module-level dictionary that
stores some information about registered components.

  >>> from pprint import pprint
  >>> from Products.CMFManagedFile.policies import registry
  >>> r = registry.Registry()
  >>> print r
  <Registry with 0 items>

Any component can be registered, the registry doesn't make any distinction:

  >>> class A: pass
  >>> r.register(A(), name='A')
  >>> print r
  <Registry with 1 items>

  >>> list(r.info())
  [{'name': 'A', 'title': 'A'}]

  >>> print r['A']
  <__builtin__.A instance registered as: A>

  >>> component = r.component('A')
  >>> print component
  <__builtin__.A instance at ...>

If the component provides a docstring, that is used as the 'title' for
the registration:

  >>> class B:
  ...   """ A component providing feature B
  ...   """

  >>> r.register(B(), name='B')
  >>> print r
  <Registry with 2 items>

  >>> pprint(list(r.info()))
  [{'name': 'A', 'title': 'A'},
   {'name': 'B', 'title': 'A component providing feature B'}]

You can also pass in a title when registering, overriding the
docstring:

  >>> r.register(B(), name='Boo', title='Foo Bar')
  >>> print r
  <Registry with 3 items>

  >>> pprint(list(r.info()))
  [{'name': 'A', 'title': 'A'},
   {'name': 'B', 'title': 'A component providing feature B'},
   {'name': 'Boo', 'title': 'Foo Bar'}]

Make sure we can clear the registry:

  >>> r.clear()
  >>> print r
  <Registry with 0 items>
