--- a/src/pyams_utils/request.py Sat Feb 17 15:53:31 2018 +0100
+++ b/src/pyams_utils/request.py Sun Feb 18 12:55:04 2018 +0100
@@ -9,6 +9,7 @@
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
+from pyams_utils.registry import get_global_registry
__docformat__ = 'restructuredtext'
@@ -113,13 +114,17 @@
return None
-def check_request(path='/', environ=None, base_url=None, headers=None, POST=None, **kw):
+def check_request(path='/', environ=None, base_url=None, headers=None, POST=None, registry=None, **kwargs):
"""Get current request, or create a new blank one if missing"""
try:
return get_request()
except MissingRequestError:
- request = Request.blank(path, environ, base_url, headers, POST, **kw)
- request.registry = get_current_registry()
+ request = Request.blank(path, environ, base_url, headers, POST, **kwargs)
+ if registry is None:
+ registry = get_current_registry()
+ if registry is None:
+ registry = get_global_registry()
+ request.registry = registry
return request