defineGroupingDirective(context, name, schema, handler, namespace='', usedIn=<InterfaceClass zope.configuration.interfaces.IConfigurationContext>)
Define a grouping directive
Define and register a factory that sets up a grouping directive.
If the namespace is '*', the directive is registered for all namespaces.
for example:
>>> context = ConfigurationMachine() >>> from zope.configuration.tests.directives import f >>> class Ixy(Interface): ... x = zope.schema.TextLine() ... y = zope.schema.TextLine()
We won't bother creating a special grouping directive class. We'll just use GroupingContextDecorator, which simply sets up a grouping context that has extra attributes defined by a schema:
>>> defineGroupingDirective(context, 'g', Ixy, ... GroupingContextDecorator, testns)
>>> context.begin((testns, "g"), x=u"vx", y=u"vy") >>> context.stack[-1].context.x u'vx' >>> context.stack[-1].context.y u'vy'
>>> context(('http://www.zope.com/t1', "g"), x=u"vx", y=u"vy") Traceback (most recent call last): ... ConfigurationError: ('Unknown directive', 'http://www.zope.com/t1', 'g')
>>> context = ConfigurationMachine() >>> defineGroupingDirective(context, 'g', Ixy, ... GroupingContextDecorator, "*")
>>> context.begin(('http://www.zope.com/t1', "g"), x=u"vx", y=u"vy") >>> context.stack[-1].context.x u'vx' >>> context.stack[-1].context.y u'vy'