本文整理匯總了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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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