python类ViewSetMixin()的实例源码

view.py 文件源码 项目:py2swagger 作者: Arello-Mobile 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def get_view_introspector(api):
    """
    Creates view introspector based on api

    :param api:
    :rtype: BaseViewIntrospector
    """
    callback = api['callback']

    def inmodule(callback, module_name):
        return callback.__module__ == module_name

    map = (
        (issubclass, ViewSetMixin, ViewSetIntrospector),
        (inmodule, 'rest_framework.decorators', WrappedApiViewIntrospector),
        (issubclass, APIView, ApiViewIntrospector),
    )

    for f, param, introspector_class in map:
        if f(callback, param):
            return introspector_class(**api)

    raise IntrospectorException('View introspector not recognized')


问题


面经


文章

微信
公众号

扫码关注公众号