# HG changeset patch # User Thierry Florac # Date 1518971657 -3600 # Node ID e7db8173ee0d5b90ecbc6ec51832cbc0eb74279d # Parent a96fc19c0109fc7229c114150dd48408e521f636 Updated request data functions exceptions handling diff -r a96fc19c0109 -r e7db8173ee0d 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