示例#1
0
 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
示例#2
0
 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
示例#3
0
    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