本文整理匯總了Python中flask._request_ctx_stack.pop方法的典型用法代碼示例。如果您正苦於以下問題:Python _request_ctx_stack.pop方法的具體用法?Python _request_ctx_stack.pop怎麽用?Python _request_ctx_stack.pop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類flask._request_ctx_stack
的用法示例。
在下文中一共展示了_request_ctx_stack.pop方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: open
# 需要導入模塊: from flask import _request_ctx_stack [as 別名]
# 或者: from flask._request_ctx_stack import pop [as 別名]
def open(self, *args, **kwargs):
as_tuple = kwargs.pop('as_tuple', False)
buffered = kwargs.pop('buffered', False)
follow_redirects = kwargs.pop('follow_redirects', False)
if (
not kwargs and len(args) == 1
and isinstance(args[0], (EnvironBuilder, dict))
):
environ = self.environ_base.copy()
if isinstance(args[0], EnvironBuilder):
environ.update(args[0].get_environ())
else:
environ.update(args[0])
environ['flask._preserve_context'] = self.preserve_context
else:
kwargs.setdefault('environ_overrides', {}) \
['flask._preserve_context'] = self.preserve_context
kwargs.setdefault('environ_base', self.environ_base)
builder = make_test_environ_builder(
self.application, *args, **kwargs
)
try:
environ = builder.get_environ()
finally:
builder.close()
return Client.open(
self, environ,
as_tuple=as_tuple,
buffered=buffered,
follow_redirects=follow_redirects
)
示例2: __exit__
# 需要導入模塊: from flask import _request_ctx_stack [as 別名]
# 或者: from flask._request_ctx_stack import pop [as 別名]
def __exit__(self, exc_type, exc_value, tb):
self.preserve_context = False
# on exit we want to clean up earlier. Normally the request context
# stays preserved until the next request in the same thread comes
# in. See RequestGlobals.push() for the general behavior.
top = _request_ctx_stack.top
if top is not None and top.preserved:
top.pop()
示例3: open
# 需要導入模塊: from flask import _request_ctx_stack [as 別名]
# 或者: from flask._request_ctx_stack import pop [as 別名]
def open(self, *args, **kwargs):
kwargs.setdefault('environ_overrides', {}) \
['flask._preserve_context'] = self.preserve_context
as_tuple = kwargs.pop('as_tuple', False)
buffered = kwargs.pop('buffered', False)
follow_redirects = kwargs.pop('follow_redirects', False)
builder = make_test_environ_builder(self.application, *args, **kwargs)
return Client.open(self, builder,
as_tuple=as_tuple,
buffered=buffered,
follow_redirects=follow_redirects)
示例4: open
# 需要導入模塊: from flask import _request_ctx_stack [as 別名]
# 或者: from flask._request_ctx_stack import pop [as 別名]
def open(self, *args, **kwargs):
kwargs.setdefault('environ_overrides', {}) \
['flask._preserve_context'] = self.preserve_context
kwargs.setdefault('environ_base', self.environ_base)
as_tuple = kwargs.pop('as_tuple', False)
buffered = kwargs.pop('buffered', False)
follow_redirects = kwargs.pop('follow_redirects', False)
builder = make_test_environ_builder(self.application, *args, **kwargs)
return Client.open(self, builder,
as_tuple=as_tuple,
buffered=buffered,
follow_redirects=follow_redirects)
示例5: pop_ctx
# 需要導入模塊: from flask import _request_ctx_stack [as 別名]
# 或者: from flask._request_ctx_stack import pop [as 別名]
def pop_ctx():
"""Removes the test context(s) from the current stack(s)
"""
if getattr(_request_ctx_stack.top, 'fixtures_request_context', False):
_request_ctx_stack.pop()
if _app_ctx_stack is not None and getattr(_app_ctx_stack.top, 'fixtures_app_context', False):
_app_ctx_stack.pop()
示例6: open
# 需要導入模塊: from flask import _request_ctx_stack [as 別名]
# 或者: from flask._request_ctx_stack import pop [as 別名]
def open(self, *args, **kwargs):
if self.context_preserved:
_request_ctx_stack.pop()
self.context_preserved = False
kwargs.setdefault('environ_overrides', {}) \
['flask._preserve_context'] = self.preserve_context
old = _request_ctx_stack.top
try:
return Client.open(self, *args, **kwargs)
finally:
self.context_preserved = _request_ctx_stack.top is not old
示例7: __exit__
# 需要導入模塊: from flask import _request_ctx_stack [as 別名]
# 或者: from flask._request_ctx_stack import pop [as 別名]
def __exit__(self, exc_type, exc_value, tb):
self.preserve_context = False
if self.context_preserved:
_request_ctx_stack.pop()