[IMP] sensible implementation of set_request
bzr revid: xmo@openerp.com-20131015094216-sgsfukzndfpu8kss
This commit is contained in:
+10
-8
@@ -471,18 +471,20 @@ from werkzeug.local import LocalStack
|
||||
|
||||
_request_stack = LocalStack()
|
||||
|
||||
def set_request(request):
|
||||
class with_obj(object):
|
||||
def __enter__(self):
|
||||
_request_stack.push(request)
|
||||
def __exit__(self, *args):
|
||||
_request_stack.pop()
|
||||
return with_obj()
|
||||
|
||||
@contextlib.contextmanager
|
||||
def set_request(req):
|
||||
_request_stack.push(req)
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
_request_stack.pop()
|
||||
|
||||
|
||||
request = _request_stack()
|
||||
"""
|
||||
A global proxy that always redirect to the current request object.
|
||||
"""
|
||||
request = _request_stack()
|
||||
|
||||
#----------------------------------------------------------
|
||||
# Controller registration with a metaclass
|
||||
|
||||
Reference in New Issue
Block a user