def make_request(request, permission, permittee, target_obj_or_class,
                 redirect_to=None):
    """When a permission is missing allow user to request a role.
    
    Show the user a list of roles that have the missing permission, and
    allow her to request the permission from a user who can give that role.
    
    @see: L{ExpedientPermission} for information about permission redirection.
    """
    
    if permittee != request.user:
        raise PermissionDenied
    
    assert(isinstance(permittee, User))
    try:
        done_url = request.session["breadcrumbs"][-1][1]
    except __HOLE__:
        done_url = reverse("home")
    # get all the roles that have this permission
    roles = ProjectRole.objects.filter_for_permission(
        permission.name, target_obj_or_class)
   
    if not roles:
       return simple.direct_to_template(
        request,
        template=TEMPLATE_PATH+"/no_permission.html",
        extra_context={
            "cancel_url": done_url,
            "target": target_obj_or_class,
        }
        )
 
    # for each role get the users that can delegate it
    roles_to_users = {}
    for r in roles:
        givers = get_users_for_role(r, can_delegate=True)
        roles_to_users[r.id] = givers

    if request.method == "POST":
        req = ProjectRoleRequest(requester=request.user)
        form = SelectRoleForm(
            roles, roles_to_users, request.POST, instance=req)
        if form.is_valid():
            req = form.save()
            DatedMessage.objects.post_message_to_user(
                "Request for '%s' role in project '%s' sent to user '%s'"
                    % (req.requested_role.name,
                       req.requested_role.project,
                       req.giver.username),
                user=request.user,
                msg_type=DatedMessage.TYPE_SUCCESS)
            return HttpResponseRedirect(done_url)
    else:
        form = SelectRoleForm(
            roles, roles_to_users)

    return simple.direct_to_template(
        request,
        template=TEMPLATE_PATH+"/make_request.html",
        extra_context={
            "cancel_url": done_url,
            "form": form,
            "target": target_obj_or_class,
        }
    )
dataset/ETHPy150Open fp7-ofelia/ocf/expedient/src/python/expedient/clearinghouse/roles/views.py/make_request