Make sure that all requests support annotations to store user data
authorThierry Florac <tflorac@ulthar.net>
Sat, 17 Feb 2018 15:53:31 +0100
changeset 136 e5a7e65ba12a
parent 135 fc98621aa9d2
child 137 a96fc19c0109
Make sure that all requests support annotations to store user data
src/pyams_utils/request.py
--- a/src/pyams_utils/request.py	Thu Feb 08 08:50:04 2018 +0100
+++ b/src/pyams_utils/request.py	Sat Feb 17 15:53:31 2018 +0100
@@ -155,9 +155,8 @@
     try:
         annotations = request.annotations
     except AttributeError:
-        return default
-    else:
-        return annotations.get(key, default)
+        annotations = get_annotations(request)
+    return annotations.get(key, default)
 
 
 def set_request_data(request, key, value):
@@ -170,6 +169,5 @@
     try:
         annotations = request.annotations
     except AttributeError:
-        pass
-    else:
-        annotations[key] = value
+        annotations = get_annotations(request)
+    annotations[key] = value