cubicweb/utils.py
changeset 12305 9fd7d496e27e
parent 12303 198cb7d7b4ac
child 12306 c96dd92e480e
--- a/cubicweb/utils.py	Tue Apr 24 15:21:38 2018 +0200
+++ b/cubicweb/utils.py	Tue Apr 24 17:30:43 2018 +0200
@@ -627,6 +627,18 @@
         with self._lock:
             return len(self._data)
 
+    def get(self, k, default=None):
+        """Get the value associated to the specified key
+
+        :param k: The key to look for
+        :param default: The default value when the key is not found
+        :return: The associated value (or the default value)
+        """
+        try:
+            return self._data[k]
+        except KeyError:
+            return default
+
     def __getitem__(self, k):
         with self._lock:
             if k in self._permanent: