当前位置: 首页>>代码示例>>Python>>正文


Python permissions.BasePermission方法代码示例

本文整理汇总了Python中rest_framework.permissions.BasePermission方法的典型用法代码示例。如果您正苦于以下问题:Python permissions.BasePermission方法的具体用法?Python permissions.BasePermission怎么用?Python permissions.BasePermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rest_framework.permissions的用法示例。


在下文中一共展示了permissions.BasePermission方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_has_role

# 需要导入模块: from rest_framework import permissions [as 别名]
# 或者: from rest_framework.permissions import BasePermission [as 别名]
def get_has_role(role_name, active_status=ActiveStatus.IS_ACTIVE):
    """
    Returns a permission class that checks if a person has a specific role
    :param role_name: the name of the role to check for
    :param active_status: the active status to look for
    :return: a permission class that can be used with DRF
    """

    class HasRole(BasePermission):
        """
        Allows access only to users having the given role
        """

        def has_permission(self, request, view):
            return get_role(
                person=request.person,
                role_name=role_name,
                active_status=active_status,
                silent=True
            ) is not None

    return HasRole 
开发者ID:IMGIITRoorkee,项目名称:omniport-backend,代码行数:24,代码来源:has_role.py

示例2: deploy_objv4_permission

# 需要导入模块: from rest_framework import permissions [as 别名]
# 或者: from rest_framework.permissions import BasePermission [as 别名]
def deploy_objv4_permission(request, *args, **kwargs):

    class Perm(BasePermission):

        def has_permission(self, request, view):
            return perm_objv4(
                request,
                AdminPermission.OBJ_UPDATE_CONFIG_OPERATION,
                AdminPermission.OBJ_TYPE_VLAN,
                *args,
                **kwargs
            )

    return Perm 
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:16,代码来源:permissions.py

示例3: write_objv4_permission

# 需要导入模块: from rest_framework import permissions [as 别名]
# 或者: from rest_framework.permissions import BasePermission [as 别名]
def write_objv4_permission(request, *args, **kwargs):

    class Perm(BasePermission):

        def has_permission(self, request, view):
            return perm_objv4(
                request,
                AdminPermission.OBJ_WRITE_OPERATION,
                AdminPermission.OBJ_TYPE_VLAN,
                *args,
                **kwargs
            )

    return Perm 
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:16,代码来源:permissions.py

示例4: delete_objv4_permission

# 需要导入模块: from rest_framework import permissions [as 别名]
# 或者: from rest_framework.permissions import BasePermission [as 别名]
def delete_objv4_permission(request, *args, **kwargs):

    class Perm(BasePermission):

        def has_permission(self, request, view):
            return perm_objv4(
                request,
                AdminPermission.OBJ_DELETE_OPERATION,
                AdminPermission.OBJ_TYPE_VLAN,
                *args,
                **kwargs
            )

    return Perm 
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:16,代码来源:permissions.py

示例5: read_objv4_permission

# 需要导入模块: from rest_framework import permissions [as 别名]
# 或者: from rest_framework.permissions import BasePermission [as 别名]
def read_objv4_permission(request, *args, **kwargs):

    class Perm(BasePermission):

        def has_permission(self, request, view):
            return perm_objv4(
                request,
                AdminPermission.OBJ_READ_OPERATION,
                AdminPermission.OBJ_TYPE_VLAN,
                *args,
                **kwargs
            )

    return Perm 
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:16,代码来源:permissions.py

示例6: deploy_objv6_permission

# 需要导入模块: from rest_framework import permissions [as 别名]
# 或者: from rest_framework.permissions import BasePermission [as 别名]
def deploy_objv6_permission(request, *args, **kwargs):

    class Perm(BasePermission):

        def has_permission(self, request, view):
            return perm_objv6(
                request,
                AdminPermission.OBJ_UPDATE_CONFIG_OPERATION,
                AdminPermission.OBJ_TYPE_VLAN,
                *args,
                **kwargs
            )

    return Perm 
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:16,代码来源:permissions.py

示例7: delete_objv6_permission

# 需要导入模块: from rest_framework import permissions [as 别名]
# 或者: from rest_framework.permissions import BasePermission [as 别名]
def delete_objv6_permission(request, *args, **kwargs):

    class Perm(BasePermission):

        def has_permission(self, request, view):
            return perm_objv6(
                request,
                AdminPermission.OBJ_DELETE_OPERATION,
                AdminPermission.OBJ_TYPE_VLAN,
                *args,
                **kwargs
            )

    return Perm 
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:16,代码来源:permissions.py

示例8: read_objv6_permission

# 需要导入模块: from rest_framework import permissions [as 别名]
# 或者: from rest_framework.permissions import BasePermission [as 别名]
def read_objv6_permission(request, *args, **kwargs):

    class Perm(BasePermission):

        def has_permission(self, request, view):
            return perm_objv6(
                request,
                AdminPermission.OBJ_READ_OPERATION,
                AdminPermission.OBJ_TYPE_VLAN,
                *args,
                **kwargs
            )

    return Perm 
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:16,代码来源:permissions.py

示例9: deploy_obj_permission

# 需要导入模块: from rest_framework import permissions [as 别名]
# 或者: from rest_framework.permissions import BasePermission [as 别名]
def deploy_obj_permission(request, *args, **kwargs):

    class Perm(BasePermission):

        def has_permission(self, request, view):
            return perm_obj(
                request,
                AdminPermission.OBJ_UPDATE_CONFIG_OPERATION,
                AdminPermission.OBJ_TYPE_VIP,
                *args,
                **kwargs
            )

    return Perm 
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:16,代码来源:permissions.py

示例10: write_obj_permission

# 需要导入模块: from rest_framework import permissions [as 别名]
# 或者: from rest_framework.permissions import BasePermission [as 别名]
def write_obj_permission(request, *args, **kwargs):

    class Perm(BasePermission):

        def has_permission(self, request, view):
            return perm_obj(
                request,
                AdminPermission.OBJ_WRITE_OPERATION,
                AdminPermission.OBJ_TYPE_VIP,
                *args,
                **kwargs
            )

    return Perm 
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:16,代码来源:permissions.py

示例11: delete_obj_permission

# 需要导入模块: from rest_framework import permissions [as 别名]
# 或者: from rest_framework.permissions import BasePermission [as 别名]
def delete_obj_permission(request, *args, **kwargs):

    class Perm(BasePermission):

        def has_permission(self, request, view):
            return perm_obj(
                request,
                AdminPermission.OBJ_DELETE_OPERATION,
                AdminPermission.OBJ_TYPE_VIP,
                *args,
                **kwargs
            )

    return Perm 
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:16,代码来源:permissions.py

示例12: deploy_obj_permission

# 需要导入模块: from rest_framework import permissions [as 别名]
# 或者: from rest_framework.permissions import BasePermission [as 别名]
def deploy_obj_permission(request, *args, **kwargs):

    class Perm(BasePermission):

        def has_permission(self, request, view):
            return perm_obj(
                request,
                AdminPermission.OBJ_UPDATE_CONFIG_OPERATION,
                AdminPermission.OBJ_TYPE_POOL,
                *args,
                **kwargs
            )

    return Perm 
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:16,代码来源:permissions.py

示例13: write_obj_permission

# 需要导入模块: from rest_framework import permissions [as 别名]
# 或者: from rest_framework.permissions import BasePermission [as 别名]
def write_obj_permission(request, *args, **kwargs):

    class Perm(BasePermission):

        def has_permission(self, request, view):
            return perm_obj(
                request,
                AdminPermission.OBJ_WRITE_OPERATION,
                AdminPermission.OBJ_TYPE_POOL,
                *args,
                **kwargs
            )

    return Perm 
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:16,代码来源:permissions.py

示例14: delete_obj_permission

# 需要导入模块: from rest_framework import permissions [as 别名]
# 或者: from rest_framework.permissions import BasePermission [as 别名]
def delete_obj_permission(request, *args, **kwargs):

    class Perm(BasePermission):

        def has_permission(self, request, view):
            return perm_obj(
                request,
                AdminPermission.OBJ_DELETE_OPERATION,
                AdminPermission.OBJ_TYPE_POOL,
                *args,
                **kwargs
            )

    return Perm 
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:16,代码来源:permissions.py

示例15: read_obj_permission

# 需要导入模块: from rest_framework import permissions [as 别名]
# 或者: from rest_framework.permissions import BasePermission [as 别名]
def read_obj_permission(request, *args, **kwargs):

    class Perm(BasePermission):

        def has_permission(self, request, view):
            return perm_obj(
                request,
                AdminPermission.OBJ_READ_OPERATION,
                AdminPermission.OBJ_TYPE_POOL,
                *args,
                **kwargs
            )

    return Perm 
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:16,代码来源:permissions.py


注:本文中的rest_framework.permissions.BasePermission方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。