original_docstring: Check authorization of a rule against the target and credentials.
  
          :param dict context: As much information about the user performing the
                               action as possible.
          :param rule: The rule to evaluate.
          :param dict target: As much information about the object being operated
                              on as possible.
          :return: ``True`` if the policy allows the action.
                   ``False`` if the policy does not allow the action.
      
docstring: Check authorization of a rule against the target and credentials.
docstring_tokens: Check authorization of a rule against the target and credentials .
code: def enforce(context, rule=None, target=None, *args, **kwargs):
      """Check authorization of a rule against the target and credentials.
  
          :param dict context: As much information about the user performing the
                               action as possible.
          :param rule: The rule to evaluate.
          :param dict target: As much information about the object being operated
                              on as possible.
          :return: ``True`` if the policy allows the action.
                   ``False`` if the policy does not allow the action.
      """
      enforcer = init()
      credentials = context.to_dict()
      if target is None:
          target = {'project_id': context.project_id,
                    'user_id': context.user_id}
  
      exc = t_exec.PolicyNotAuthorized
  
      try:
          result = enforcer.enforce(rule, target, credentials,
                                    do_raise=True, exc=exc, *args, **kwargs)
  
      except t_exec.PolicyNotAuthorized as e:
          result = False
          LOG.exception(_LE("%(msg)s, %(rule)s, %(target)s"),
                        {'msg': str(e), 'rule': rule, 'target': target})
      return result
code_tokens: def enforce ( context , rule = None , target = None , * args , ** kwargs ) : enforcer = init ( ) credentials = context . to_dict ( ) if target is None : target = { 'project_id' : context . project_id , 'user_id' : context . user_id } exc = t_exec . PolicyNotAuthorized try : result = enforcer . enforce ( rule , target , credentials , do_raise = True , exc = exc , * args , ** kwargs ) except t_exec . PolicyNotAuthorized as e : result = False LOG . exception ( _LE ( "%(msg)s, %(rule)s, %(target)s" ) , { 'msg' : str ( e ) , 'rule' : rule , 'target' : target } ) return result
short_docstring: Check authorization of a rule against the target and credentials.
short_docstring_tokens: Check authorization of a rule against the target and credentials .
comment: """Check authorization of a rule against the target and credentials.
  
          :param dict context: As much information about the user performing the
                               action as possible.
          :param rule: The rule to evaluate.
          :param dict target: As much information about the object being operated
                              on as possible.
          :return: ``True`` if the policy allows the action.
                   ``False`` if the policy does not allow the action.
      """