--- a/src/pyams_utils/vocabulary.py Tue Nov 15 10:43:55 2016 +0100
+++ b/src/pyams_utils/vocabulary.py Fri Nov 18 15:28:54 2016 +0100
@@ -26,7 +26,28 @@
class vocabulary_config:
- """Class decorator to define a vocabulary"""
+ """Class decorator to define a vocabulary
+
+ :param str name: name of the registered vocabulary
+
+ This is, for example, how a vocabulary of registered ZEO connections utilities is created:
+
+ .. code-block:: python
+
+ from pyams_utils.interfaces.zeo import IZEOConnection
+
+ from pyams_utils.registry import get_utilities_for
+ from pyams_utils.vocabulary import voacbulary_config
+ from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
+
+ @vocabulary_config(name='PyAMS ZEO connections')
+ class ZEOConnectionVocabulary(SimpleVocabulary):
+ '''ZEO connections vocabulary'''
+
+ def __init__(self, context=None):
+ terms = [SimpleTerm(name, title=util.name) for name, util in get_utilities_for(IZEOConnection)]
+ super(ZEOConnectionVocabulary, self).__init__(terms)
+ """
def __init__(self, name):
self.name = name