7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED |
7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED |
8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
10 # FOR A PARTICULAR PURPOSE. |
10 # FOR A PARTICULAR PURPOSE. |
11 # |
11 # |
|
12 from pyams_utils.registry import get_global_registry |
12 |
13 |
13 __docformat__ = 'restructuredtext' |
14 __docformat__ = 'restructuredtext' |
14 |
15 |
15 |
16 |
16 # import standard library |
17 # import standard library |
111 return get_request() |
112 return get_request() |
112 except MissingRequestError: |
113 except MissingRequestError: |
113 return None |
114 return None |
114 |
115 |
115 |
116 |
116 def check_request(path='/', environ=None, base_url=None, headers=None, POST=None, **kw): |
117 def check_request(path='/', environ=None, base_url=None, headers=None, POST=None, registry=None, **kwargs): |
117 """Get current request, or create a new blank one if missing""" |
118 """Get current request, or create a new blank one if missing""" |
118 try: |
119 try: |
119 return get_request() |
120 return get_request() |
120 except MissingRequestError: |
121 except MissingRequestError: |
121 request = Request.blank(path, environ, base_url, headers, POST, **kw) |
122 request = Request.blank(path, environ, base_url, headers, POST, **kwargs) |
122 request.registry = get_current_registry() |
123 if registry is None: |
|
124 registry = get_current_registry() |
|
125 if registry is None: |
|
126 registry = get_global_registry() |
|
127 request.registry = registry |
123 return request |
128 return request |
124 |
129 |
125 |
130 |
126 def get_annotations(request): |
131 def get_annotations(request): |
127 """Define 'annotations' request property |
132 """Define 'annotations' request property |