本文整理汇总了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