Пример #1
0
    def _init_resource(self, key, resource):
        if not is_generator(resource):
            raise Exception('Resource {}:{} must be a Python generator callable.'.format(key, resource))

        if hasattr(resource, 'setup') and callable(resource.setup):
            # Setup is deprecated as of 0.8.4
            resource.setup(self._data_manager)

        self._resources[key] = resource
Пример #2
0
    def register_context_middleware(self, *middleware):
        """
        :param middleware: Middleware in order of execution
        """
        for m in middleware:
            if not is_generator(m):
                raise Exception('Middleware {} must be a Python generator callable.'.format(m))

        self._middleware.extend(middleware)
Пример #3
0
    def register_context_middleware(self, *middleware):
        """
        :param middleware: Middleware in order of execution
        """
        for m in middleware:
            if not is_generator(m):
                raise Exception('Middleware {} must be a Python generator callable.'.format(m))

        self._middleware.extend(middleware)
Пример #4
0
    def _init_resource(self, key, resource):
        if not is_generator(resource):
            raise Exception(
                'Resource {}:{} must be a Python generator callable.'.format(
                    key, resource))

        if hasattr(resource, 'setup') and callable(resource.setup):
            # Setup is deprecated as of 0.8.4
            resource.setup(self._data_manager)

        self._resources[key] = resource