def registerPreferenceGroupDirective(_context, annotation_factory, directive_name, group_id):

    utility(_context, IPreferenceAnnotationFactory, annotation_factory, name=group_id)

    def customPreferenceGroup(_context, id=None, schema=None,
                              title=u'', description=u'', category=False):

        dotted_id = '%s.%s' % (group_id, id)
        id = dotted_id if id else id
        group = PreferenceGroup(id, annotation_factory, schema, title, description, category)
        utility(_context, IPreferenceGroup, group, name=id)

    defineSimpleDirective(_context,
                          name=directive_name,
                          schema=IPreferenceGroup,
                          handler=customPreferenceGroup)
Exemplo n.º 2
0
def registerCommonDirectives(context):
    # We have to use the direct definition functions to define
    # a directive for all namespaces.

    config.defineSimpleDirective(
        context, "include", IInclude, include, namespace="*")

    config.defineSimpleDirective(
        context, "includeOverrides", IInclude, includeOverrides, namespace="*")

    config.defineGroupingDirective(
        context,
        name="configure",
        namespace="*",
        schema=IZopeConfigure,
        handler=ZopeConfigure,
        )
Exemplo n.º 3
0
def registerCommonDirectives(context):
    # We have to use the direct definition functions to define
    # a directive for all namespaces.

    config.defineSimpleDirective(context,
                                 "include",
                                 IInclude,
                                 include,
                                 namespace="*")

    config.defineSimpleDirective(context,
                                 "exclude",
                                 IInclude,
                                 exclude,
                                 namespace="*")

    config.defineSimpleDirective(context,
                                 "includeOverrides",
                                 IInclude,
                                 includeOverrides,
                                 namespace="*")

    config.defineGroupingDirective(
        context,
        name="configure",
        namespace="*",
        schema=IZopeConfigure,
        handler=ZopeConfigure,
    )
Exemplo n.º 4
0
def zcml(source):
    context = config.ConfigurationMachine()
    xmlconfig.registerCommonDirectives(context)

    # Test directives
    config.defineSimpleDirective(context,
                                 "print",
                                 IPrint,
                                 print_,
                                 namespace="*")
    config.defineSimpleDirective(context,
                                 "lolcat",
                                 ILolCat,
                                 lolcat,
                                 namespace="*")

    source = '''\
<configure package="z3c.unconfigure.tests.fixtures">
%s
</configure>''' % source

    xmlconfig.string(source, context)