def grok(self, name, factory, context, module_info, templates): provides = util.class_annotation(factory, 'grok.provides', None) if provides is None: util.check_implements_one(factory) name = util.class_annotation(factory, 'grok.name', '') component.provideUtility(factory(), provides=provides, name=name) return True
def grok(self, name, factory, context, module_info, templates): adapter_context = util.determine_class_context(factory, context) provides = util.class_annotation(factory, 'grok.provides', None) if provides is None: util.check_implements_one(factory) name = util.class_annotation(factory, 'grok.name', '') component.provideAdapter(factory, adapts=(adapter_context,), provides=provides, name=name) return True
def grok(self, name, module, context, module_info, templates): infos = module_info.getAnnotation('grok.global_utility', []) for info in infos: if info.provides is None: util.check_implements_one(info.factory) if info.direct: obj = info.factory else: obj = info.factory() component.provideUtility(obj, provides=info.provides, name=info.name) return True