當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。