context.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:aiohttp_json_api 作者: vovanbo 项目源码 文件源码
def parse_request_includes(cls, request: web.Request) -> RequestIncludes:
        """
        Parse compound documents parameters from request query string.

        Returns the names of the relationships, which should be included into
        the response.

        .. code-block:: python3

            >>> from aiohttp_json_api.context import JSONAPIContext
            >>> from aiohttp.test_utils import make_mocked_request
            >>> request = make_mocked_request('GET', '/api/Post?include=author,comments.author,some-field.nested')
            >>> JSONAPIContext.parse_request_includes(request)
            (('author',), ('comments', 'author'), ('some_field', 'nested'))

        :seealso: http://jsonapi.org/format/#fetching-includes
        """
        return tuple(
            tuple(cls.convert_field_name(p) for p in path.split('.'))
            for path in request.query.get('include', '').split(',') if path
        )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号