From d0f464c27cd2e16ee1049a158bd453f57124ec92 Mon Sep 17 00:00:00 2001 From: sgdt6900 Date: Thu, 21 Dec 2017 11:39:47 +0200 Subject: comments needed to be done Change-Id: I0214fa7d30539daa0fc0e62465299ebf643eb356 Signed-off-by: sgdt6900 --- moonv4/moon_utilities/moon_utilities/cache.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'moonv4/moon_utilities') diff --git a/moonv4/moon_utilities/moon_utilities/cache.py b/moonv4/moon_utilities/moon_utilities/cache.py index d62c9d54..8c6ee3bf 100644 --- a/moonv4/moon_utilities/moon_utilities/cache.py +++ b/moonv4/moon_utilities/moon_utilities/cache.py @@ -9,6 +9,12 @@ LOG = logging.getLogger("moon.utilities.cache") class Cache(object): # TODO (asteroide): set cache integer in CONF file + ''' + [NOTE] Propose to define the following variables inside the init method + as defining them out side the init, will be treated as private static variables + and keep tracks with any changes done anywhere + for more info : you can check https://docs.python.org/3/tutorial/classes.html#class-and-instance-variables + ''' __UPDATE_INTERVAL = 10 __CONTAINERS = {} @@ -196,6 +202,15 @@ class Cache(object): def get_subject_assignments(self, policy_id, perimeter_id, category_id): if policy_id not in self.subject_assignments: self.update_subject_assignments(policy_id, perimeter_id) + ''' + [NOTE] invalid condition for testing existence of policy_id + because update_subject_assignments function already add an empty object + with the given policy_id and then assign the response to it + as mentioned in these lines of code (line 191,192) + + Note: the same condition applied for the object,action assignment + line 234, 260 + ''' if policy_id not in self.subject_assignments: raise Exception("Cannot found the policy {}".format(policy_id)) for key, value in self.subject_assignments[policy_id].items(): -- cgit 1.2.3-korg