views.py 文件源码

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

项目:apimas 作者: grnet 项目源码 文件源码
def get_bases_classes(mixins, hook_class, actions):
    """
    This function gets the corresponding base classes in order to construct
    the viewset class.

    A model can specify the allowed operations to it, e.g. update,
    list, delete, etc. Then, a viewset specify the allowed methods based on
    model's allowed operations by defining the corresponding bases classes.

    By default, all methods are allowed.

    Apart from this, also configration object can also include custom mixins
    classes. Therefore, they are also added to the list of bases classes.

    :returns: A tuple of the corresponding base classes.
    """
    hook_class = utils.import_object(hook_class) if hook_class\
        else view_mixins.HookMixin
    mixins = map(utils.LOAD_CLASS, mixins)
    bases = (viewsets.GenericViewSet,) if not actions\
        else tuple([MIXINS[action] for action in actions]) + (
            viewsets.GenericViewSet,)
    return (hook_class,) + tuple(mixins) + tuple(bases)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号