Updated request data functions exceptions handling
authorThierry Florac <tflorac@ulthar.net>
Sun, 18 Feb 2018 17:34:17 +0100
changeset 138 e7db8173ee0d
parent 137 a96fc19c0109
child 139 6daed68877b3
Updated request data functions exceptions handling
src/pyams_utils/request.py
--- a/src/pyams_utils/request.py	Sun Feb 18 12:55:04 2018 +0100
+++ b/src/pyams_utils/request.py	Sun Feb 18 17:34:17 2018 +0100
@@ -9,7 +9,6 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
-from pyams_utils.registry import get_global_registry
 
 __docformat__ = 'restructuredtext'
 
@@ -22,6 +21,7 @@
 from zope.annotation.interfaces import IAttributeAnnotatable, IAnnotations
 
 # import packages
+from pyams_utils.registry import get_global_registry
 from pyramid.request import Request
 from pyramid.security import Allowed
 from pyramid.threadlocal import get_current_request, get_current_registry
@@ -159,7 +159,7 @@
     """
     try:
         annotations = request.annotations
-    except AttributeError:
+    except (TypeError, AttributeError) as e:
         annotations = get_annotations(request)
     return annotations.get(key, default)
 
@@ -173,6 +173,6 @@
     """
     try:
         annotations = request.annotations
-    except AttributeError:
+    except (TypeError, AttributeError) as e:
         annotations = get_annotations(request)
     annotations[key] = value