Added MissingRequestError exception class
authorThierry Florac <tflorac@ulthar.net>
Sat, 14 Mar 2015 13:49:25 +0100
changeset 21 b1b92e017581
parent 20 4bbf6181e1cf
child 22 e51d9ae05145
Added MissingRequestError exception class
src/pyams_utils/request.py
--- a/src/pyams_utils/request.py	Sat Mar 14 13:49:03 2015 +0100
+++ b/src/pyams_utils/request.py	Sat Mar 14 13:49:25 2015 +0100
@@ -16,8 +16,8 @@
 # import standard library
 
 # import interfaces
+from pyams_utils.interfaces import MissingRequestError
 from zope.annotation.interfaces import IAttributeAnnotatable, IAnnotations
-from zope.security.interfaces import NoInteraction
 
 # import packages
 from pyramid.request import Request
@@ -31,7 +31,7 @@
     Raises a NoInteraction exception if there is no active request"""
     request = get_current_request()
     if (request is None) and raise_exception:
-        raise NoInteraction("No request")
+        raise MissingRequestError("No request")
     return request
 
 
@@ -41,7 +41,7 @@
     Returns None if there is no active request"""
     try:
         return get_request()
-    except NoInteraction:
+    except MissingRequestError:
         return None
 
 
@@ -49,7 +49,7 @@
     """Get current request, or create a new blank one if missing"""
     try:
         return get_request()
-    except NoInteraction:
+    except MissingRequestError:
         return Request.blank(path, environ, base_url, headers, POST, **kw)