def get_users_for_role(role, can_delegate=False):
    # get all the permissions in the role
    obj_perm_ids = role.obj_permissions.values_list("pk", flat=True)
    
    # Filter for all the ids
    qs = Permittee.objects.all()
    for id in obj_perm_ids:
        if can_delegate:
            qs = qs.filter(
                permissionownership__obj_permission__pk=id,
                permissionownership__can_delegate=True).distinct()
        else:
            qs = qs.filter(
                permissionownership__obj_permission__pk=id).distinct()
        
    user_ids = qs.values_list("object_id", flat=True)
    return User.objects.filter(pk__in=user_ids)
Get a session instance from storage given its session id.
dataset/ETHPy150Open fp7-ofelia/ocf/expedient/src/python/expedient/clearinghouse/roles/utils.py/get_users_for_role--crossover with--dataset/ETHPy150Open google/simian/src/simian/auth/base.py/AuthSessionDict._Get