def scoped_to(self, scope):
        """
        Context manager to switch scopes.

        """
        previous_scope = self.__factory__.current_scope
        try:
            self.__factory__.current_scope = scope
            yield
        finally:
            self.__factory__.current_scope = previous_scope