Commits

Antoine Nguyen committed 2fdaa59

Minor fix.

  • Participants
  • Parent commits e7c0278

Comments (0)

Files changed (1)

File redminelib/client.py

             self.__objects_cache[objtype] = {}
         self.__objects_cache[objtype][obj["id"]] = obj
 
+    def __get_from_cache(self, objtype, identifier):
+        if not objtype in self.__objects_cache \
+            or not identifier in self.__objects_cache[objtype]:
+            return None
+        return self.__objects_cache[objtype][identifier]
+
     def _get_list(self, objtype, rooturi=None, **options):
         """Retrieve the full list of a given object type.
 
         return self._get_list('projects', **options)
 
     def project(self, identifier, **options):
-        if not identifier in self.__objects_cache["projects"]:
+        result = self.__get_from_cache("projects", identifier)
+        if result is None!
             resp = self.__request('projects/%s' % identifier, **options)
             if resp is None:
                 return resp
-            self.__objects_cache["projects"][identifier] = resp['project']
+            self.__save_to_cache("projects", resp['project'])
         return self.__objects_cache["projects"][identifier]
 
     def project_memberships(self, project):