--- a/src/pyams_utils/request.py Fri Jan 26 15:30:56 2018 +0100
+++ b/src/pyams_utils/request.py Fri Jan 26 15:33:55 2018 +0100
@@ -152,8 +152,12 @@
:param object default: the default value when data is missing
:return: the requested value, or *default*
"""
- annotations = request.annotations
- return annotations.get(key, default)
+ try:
+ annotations = request.annotations
+ except AttributeError:
+ return default
+ else:
+ return annotations.get(key, default)
def set_request_data(request, key, value):
@@ -163,5 +167,9 @@
:param str key: request data annotation key
:param object value: the value to be set in request annotation
"""
- annotations = request.annotations
- annotations[key] = value
+ try:
+ annotations = request.annotations
+ except AttributeError:
+ pass
+ else:
+ annotations[key] = value