Apply current registry when creating request from scratch
authorThierry Florac <thierry.florac@onf.fr>
Tue, 17 Mar 2015 16:04:14 +0100
changeset 23 53a3bfbe6e41
parent 22 e51d9ae05145
child 24 98d0305e0587
Apply current registry when creating request from scratch
src/pyams_utils/request.py
--- a/src/pyams_utils/request.py	Sat Mar 14 13:50:21 2015 +0100
+++ b/src/pyams_utils/request.py	Tue Mar 17 16:04:14 2015 +0100
@@ -21,7 +21,7 @@
 
 # import packages
 from pyramid.request import Request
-from pyramid.threadlocal import get_current_request
+from pyramid.threadlocal import get_current_request, get_current_registry
 from zope.interface import alsoProvides
 
 
@@ -50,7 +50,9 @@
     try:
         return get_request()
     except MissingRequestError:
-        return Request.blank(path, environ, base_url, headers, POST, **kw)
+        request = Request.blank(path, environ, base_url, headers, POST, **kw)
+        request.registry = get_current_registry()
+        return request
 
 
 def get_annotations(request):