Python rest_framework.permissions 模块,BasePermission() 实例源码

我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用rest_framework.permissions.BasePermission()

项目:State-TalentMAP-API    作者:18F    | 项目源码 | 文件源码
def isDjangoGroupMember(group_name):
    '''
    Dynamically creates a permission class for the specified group, for use
    in class-based DRF views
    '''

    class IsDjangoGroupMember(permissions.BasePermission):
        def has_permission(self, request, view):
            try:
                in_group_or_403(request.user, group_name)
                return True
            except:
                return False

    return IsDjangoGroupMember