From a9f52d7c1849d703cb3cfa5332ccf2726706053a Mon Sep 17 00:00:00 2001 From: hardik Date: Wed, 15 Jun 2016 12:15:56 +0530 Subject: [PATCH] Added doc string for enforce method Change-Id: Ibe5171d4dcf3a6a483c3f9253044dcbf4bebeda5 --- mistral/api/access_control.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/mistral/api/access_control.py b/mistral/api/access_control.py index 30a426638..6fa0eea33 100644 --- a/mistral/api/access_control.py +++ b/mistral/api/access_control.py @@ -41,6 +41,23 @@ def setup(app): def enforce(action, context, target=None, do_raise=True, exc=exc.NotAllowedException): + """Verifies that the action is valid on the target in this context. + + :param action: String, representing the action to be checked. + This should be colon separated for clarity. + i.e. ``workflows:create`` + :param context: Mistral context. + :param target: Dictionary, representing the object of the action. + For object creation, this should be a dictionary + representing the location of the object. + e.g. ``{'project_id': context.project_id}`` + :param do_raise: if True (the default), raises specified excepion. + :param exc: Exception to be raised if not authorized. Default is + mistral.exceptions.NotAllowedException. + + :return: returns True if authorized and False if not authorized and + do_raise is False. + """ target_obj = { 'project_id': context.project_id, 'user_id': context.user_id,