ZCML directives
===============

The layout directive is a convenient way to register a layout
directory.

First we load the meta configuration to make the directive available.

  >>> import repoze.bfg.layouts
  >>> from zope.configuration.xmlconfig import xmlconfig, XMLConfig
  >>> XMLConfig('meta.zcml', repoze.bfg.layouts)()

Load example layout directory configuration.    

  >>> zcml="""
  ... <configure xmlns="http://namespaces.repoze.org/bfg">
  ...    <layouts
  ...       directory="%(path)s/layouts"
  ...       for="*"
  ...       request_type="*" />
  ... </configure>
  ... """ % locals()

  >>> from StringIO import StringIO
  >>> xmlconfig(StringIO(zcml))

Verify that the layout directory has been registered as a component:

  >>> context = request = object()
  >>> from repoze.bfg.layouts.interfaces import ILayoutDirectory
  >>> name, directory = tuple(component.getAdapters(
  ...     (context, request), ILayoutDirectory))[0]

The directory is registered as a component with the path as the name.

  >>> name
  u'.../tests/layouts'

Verify that we can get to the layouts.

  >>> from repoze.bfg.layouts import get_layout
  >>> get_layout(context, request, 'example')
  <Layout filename=".../tests/layouts/example.html">
