From 797171f7bf5e206ed3a8ec0d1faa69964707b9aa Mon Sep 17 00:00:00 2001
From: Lauri Himanen <lauri.himanen@aalto.fi>
Date: Thu, 4 Oct 2018 10:24:12 +0300
Subject: [PATCH] Fixed issue with CacheService trying to access the value of a
 non-existing CacheObject.

---
 common/python/nomadcore/baseclasses.py | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/common/python/nomadcore/baseclasses.py b/common/python/nomadcore/baseclasses.py
index dd4b58d..1a97c60 100644
--- a/common/python/nomadcore/baseclasses.py
+++ b/common/python/nomadcore/baseclasses.py
@@ -558,12 +558,17 @@ class CacheService(object):
         """Get the value identified by name. If the cachemode does not support
         getting the value, an exception is raised.
 
-        returns:
+        Args:
+            name(string): The name of the cached object to return.
 
-        raises:
+        Returns:
+            The requested object from the cache
         """
         cache_object = self.get_cache_object(name)
-        return cache_object.value
+        if cache_object is None:
+            return None
+        else:
+            return cache_object.value
 
     def get_cache_object(self, name):
 
@@ -575,8 +580,7 @@ class CacheService(object):
 
     def __setitem__(self, name, value):
         """Used to set the value for an item. The CacheObject corresponding to
-        the name has to be first created by using the function
-        add_cache_object().
+        the name has to be first dclared by using the function add().
         """
         cache_object = self._cache[name]
         cache_object.value = value
-- 
GitLab