Simple adapter registry that manages directives as adapters
>>> r = ConfigurationAdapterRegistry() >>> c = ConfigurationMachine() >>> r.factory(c, ('http://www.zope.com','xxx')) Traceback (most recent call last): ... ConfigurationError: ('Unknown directive', 'http://www.zope.com', 'xxx') >>> from zope.configuration.interfaces import IConfigurationContext >>> def f(): ... pass
>>> r.register(IConfigurationContext, ('http://www.zope.com', 'xxx'), f) >>> r.factory(c, ('http://www.zope.com','xxx')) is f 1 >>> r.factory(c, ('http://www.zope.com','yyy')) is f Traceback (most recent call last): ... ConfigurationError: ('Unknown directive', 'http://www.zope.com', 'yyy') >>> r.register(IConfigurationContext, 'yyy', f) >>> r.factory(c, ('http://www.zope.com','yyy')) is f 1
Test the documentation feature:
>>> r._docRegistry [] >>> r.document(('ns', 'dir'), IFullInfo, IConfigurationContext, None, ... 'inf', None) >>> r._docRegistry[0][0] == ('ns', 'dir') 1 >>> r._docRegistry[0][1] is IFullInfo 1 >>> r._docRegistry[0][2] is IConfigurationContext 1 >>> r._docRegistry[0][3] is None 1 >>> r._docRegistry[0][4] == 'inf' 1 >>> r._docRegistry[0][5] is None 1 >>> r.document('all-dir', None, None, None, None) >>> r._docRegistry[1][0] ('', 'all-dir')
There are no implemented interfaces.
There are no attributes in this class.
document(name, schema, usedIn, handler, info, parent=None)
factory(context, name)
register(interface, name, factory)