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
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)
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)