src/polydatum/context.py
def _setup(self):
        """
        Setup the context. Should only be called by
        __enter__'ing the context.
        """
        self.data_manager.ctx_stack.push(self)
        self._setup_hook()

        middleware = self.data_manager.get_middleware(self)

        # Create each middleware generator
        # This just calls each middleware and passes it the current context.
        # The middleware should then yield once.
        self._middleware_generators = [
            (m, m(self)) for m in middleware
        ]

        for middleware, generator in self._middleware_generators:
            try:
                generator.next()
            except StopIteration:
                # Middleware didn't want to setup, but did not
                # raise an exception. Why not?
                raise MiddlewareSetupException('Middleware %s did not yield on setup.' % middleware)
def _setup(self):
        """
        Setup the context. Should only be called by
        __enter__'ing the context.
        """
        self.data_manager.ctx_stack.push(self)
        self._setup_hook()

        middleware = self.data_manager.get_middleware(self)

        # Create each middleware generator
        # This just calls each middleware and passes it the current context.
        # The middleware should then yield once.
        self._middleware_generators = [
            (m, m(self)) for m in middleware
        ]

        for middleware, generator in self._middleware_generators:
            try:
                generator.next()
            except StopIteration:
                # Middleware didn't want to setup, but did not
                # raise an exception. Why not?
                raise MiddlewareSetupException('Middleware %s did not yield on setup.' % middleware)
Setup the context. Should only be called by
        __enter__'ing the context.