Function
zope.configuration.config.defineSimpleDirective

Signature

defineSimpleDirective(context, name, schema, handler, namespace='', usedIn=<InterfaceClass zope.configuration.interfaces.IConfigurationContext>)

Documentation String

Define a simple directive

Define and register a factory that invokes the simple directive and returns a new stack item, which is always the same simple stack item.

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()
>>> def s(context, x, y):
...    context.action(('s', x, y), f)
>>> defineSimpleDirective(context, 's', Ixy, s, testns)
>>> context((testns, "s"), x=u"vx", y=u"vy")
>>> context.actions
[(('s', u'vx', u'vy'), f)]
>>> context(('http://www.zope.com/t1', "s"), x=u"vx", y=u"vy")
Traceback (most recent call last):
...
ConfigurationError: ('Unknown directive', 'http://www.zope.com/t1', 's')
>>> context = ConfigurationMachine()
>>> defineSimpleDirective(context, 's', Ixy, s, "*")
>>> context(('http://www.zope.com/t1', "s"), x=u"vx", y=u"vy")
>>> context.actions
[(('s', u'vx', u'vy'), f)]