Example #1
0
    def get(self, what, default=internal.raiseOnMissing):
        ret = default
        try:
            log.debug("Resolving '%s'", what)

            ip = inject_param(what)
            bound = self._binds.get(what)

            ctx = InjectionContext(self._binds, bound, ip)
            ret = ctx.activate()
        except InjectionError:
            if default == internal.raiseOnMissing:
                raise

        log.debug("IoC '%s' resolved to '%s'", what, ret)
        return ret
Example #2
0
 def inject(self, into):
     log.debug("Injecting dependencies into '%s'", into)
     ip = inject_param(into.__class__)
     ctx = InjectionContext(self._binds, InstanceBinding(into, NoScope), ip)
     ctx.inject(into)