示例#1
0
    def grok(self, name, module, module_info, config, **kw):
        infos = grokcore.component.global_utility.bind().get(module)

        for factory, provides, name, direct in infos:
            if direct is None:
                direct = grokcore.component.direct.bind().get(factory)
            if provides is None:
                bound = grokcore.component.provides.bind(default=None)
                provides = bound.get(factory)
            if not name:
                name = grokcore.component.name.bind().get(factory)

            if direct:
                obj = factory
                if provides is None:
                    martian.util.check_provides_one(obj)
                    provides = list(interface.providedBy(obj))[0]
            else:
                obj = factory()
                if provides is None:
                    provides = _provides(factory)

            config.action(
                discriminator=('utility', provides, name),
                callable=grokcore.component.provideUtility,
                args=(obj, provides, name),
                )

        return True
示例#2
0
    def grok(self, name, module, module_info, config, **kw):
        infos = grokcore.component.global_utility.bind().get(module)

        for factory, provides, name, direct in infos:
            if direct is None:
                direct = grokcore.component.direct.bind().get(factory)
            if provides is None:
                bound = grokcore.component.provides.bind(default=None)
                provides = bound.get(factory)
            if not name:
                name = grokcore.component.name.bind().get(factory)

            if direct:
                obj = factory
                if provides is None:
                    martian.util.check_provides_one(obj)
                    provides = list(interface.providedBy(obj))[0]
            else:
                obj = factory()
                if provides is None:
                    provides = _provides(factory)

            config.action(
                discriminator=('utility', provides, name),
                callable=grokcore.component.provideUtility,
                args=(obj, provides, name),
            )

        return True
示例#3
0
def default_global_utility_provides(component, module, direct, **data):
    if direct:
        martian.util.check_provides_one(component)
        return list(interface.providedBy(component))[0]
    return _provides(component)
示例#4
0
def default_global_utility_provides(component, module, direct, **data):
    if direct:
        martian.util.check_provides_one(component)
        return list(interface.providedBy(component))[0]
    return _provides(component)
示例#5
0
文件: meta.py 项目: grodniewicz/oship
def default_global_utility_provides(factory, module, direct, **data):
    if direct:
        martian.util.check_provides_one(factory)
        return list(interface.providedBy(factory))[0]
    return default_provides(factory)