def RenderAjax(self, request, response):
    approval_urn = rdfvalue.RDFURN(request.REQ.get("acl", "/"))
    _, namespace, _ = approval_urn.Split(3)

    if namespace == "hunts":
      try:
        _, _, hunt_id, user, reason = approval_urn.Split()
        self.subject = rdfvalue.RDFURN(namespace).Add(hunt_id)
        self.user = user
        self.reason = utils.DecodeReasonString(reason)
      except (ValueError, TypeError):
        raise access_control.UnauthorizedAccess(
            "Approval object is not well formed.")

      flow.GRRFlow.StartFlow(flow_name="GrantHuntApprovalFlow",
                             subject_urn=self.subject, reason=self.reason,
                             delegate=self.user, token=request.token)
    elif namespace == "cron":
      try:
        _, _, cron_job_name, user, reason = approval_urn.Split()
        self.subject = rdfvalue.RDFURN(namespace).Add(cron_job_name)
        self.user = user
        self.reason = utils.DecodeReasonString(reason)
      except (ValueError, TypeError):
        raise access_control.UnauthorizedAccess(
            "Approval object is not well formed.")

      flow.GRRFlow.StartFlow(flow_name="GrantCronJobApprovalFlow",
                             subject_urn=self.subject, reason=self.reason,
                             delegate=self.user, token=request.token)
    elif aff4.AFF4Object.VFSGRRClient.CLIENT_ID_RE.match(namespace):
      try:
        _, client_id, user, reason = approval_urn.Split()
        self.subject = client_id
        self.user = user
        self.reason = utils.DecodeReasonString(reason)
      except (ValueError, TypeError):
        raise access_control.UnauthorizedAccess(
            "Approval object is not well formed.")

      flow.GRRFlow.StartFlow(client_id=client_id,
                             flow_name="GrantClientApprovalFlow",
                             reason=self.reason, delegate=self.user,
                             subject_urn=rdf_client.ClientURN(self.subject),
                             token=request.token)
    else:
      raise access_control.UnauthorizedAccess(
          "Approval object is not well formed.")

    return renderers.TemplateRenderer.Layout(self, request, response,
                                             apply_template=self.ajax_template)
Run the flow for granting access.
dataset/ETHPy150Open google/grr/grr/gui/plugins/acl_manager.py/GrantAccess.RenderAjax