Beispiel #1
0
    def _resolve_key(self, key):
        """
        Attempt to lazily create a component.

        :raises NotBoundError: if the component does not have a bound factory
        :raises CyclicGraphError: if the factory function requires a cycle
        :raises LockedGraphError: if the graph is locked
        """
        with self._reserve(key):
            factory = self.factory_for(key)
            with self._profiler(key):
                component = factory(self)
            invoke_resolve_hook(component)

        return self.assign(key, component)
    def _resolve_key(self, key):
        """
        Attempt to lazily create a component.

        :raises NotBoundError: if the component does not have a bound factory
        :raises CyclicGraphError: if the factory function requires a cycle
        :raises LockedGraphError: if the graph is locked
        """
        with self._reserve(key):
            factory = self._registry.resolve(key)
            component = factory(self)
            invoke_resolve_hook(component)

        self._components[key] = component
        return component
Beispiel #3
0
    def _resolve_key(self, key):
        """
        Attempt to lazily create a component.

        :raises NotBoundError: if the component does not have a bound factory
        :raises CyclicGraphError: if the factory function requires a cycle
        :raises LockedGraphError: if the graph is locked
        """
        with self._reserve(key):
            factory = self._registry.resolve(key)
            component = factory(self)
            invoke_resolve_hook(component)

        self._components[key] = component
        return component
def configure_connexion(graph):
    """
    Creates and configures connexion's app instance
    :param graph: Instance of microcosm graph
    :return: connexion instance
    """
    options = {"swagger_ui": graph.config.connexion.enable_swagger_ui}

    connexion_app = connexion.App(graph.metadata.import_name,
                                  host=graph.config.connexion.host,
                                  port=graph.config.connexion.port,
                                  debug=graph.metadata.debug,
                                  options=options)

    app = connexion_app.app
    app.debug = graph.metadata.debug
    app.testing = graph.metadata.testing

    invoke_resolve_hook(app)

    graph.assign("flask", app)
    graph.assign("app", app)

    return connexion_app