def policy_enforce(handler):
 @six.wraps(handler)
 def handle_stack_method(controller, req, tenant_id, **kwargs):
  if ((req.context.tenant_id != tenant_id) and (not req.context.is_admin)):
   raise exc.HTTPForbidden()
  allowed = req.context.policy.enforce(context=req.context, action=handler.__name__, scope=controller.REQUEST_SCOPE)
  if (not allowed):
   raise exc.HTTPForbidden()
  return handler(controller, req, **kwargs)
 return handle_stack_method

def policy_enforce ( handler ) : @ six . wraps ( handler ) def handle_stack_method ( controller , req , tenant_id , ** kwargs ) : if ( ( req . context . tenant_id != tenant_id ) and ( not req . context . is_admin ) ) : raise exc . HTTPForbidden ( ) allowed = req . context . policy . enforce ( context = req . context , action = handler . __name__ , scope = controller . REQUEST_SCOPE ) if ( not allowed ) : raise exc . HTTPForbidden ( ) return handler ( controller , req , ** kwargs ) return handle_stack_method
decorator that enforces policies .