本文整理匯總了Python中flask.globals.request.blueprint方法的典型用法代碼示例。如果您正苦於以下問題:Python request.blueprint方法的具體用法?Python request.blueprint怎麽用?Python request.blueprint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類flask.globals.request
的用法示例。
在下文中一共展示了request.blueprint方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _dump_arg_defaults
# 需要導入模塊: from flask.globals import request [as 別名]
# 或者: from flask.globals.request import blueprint [as 別名]
def _dump_arg_defaults(kwargs):
"""Inject default arguments for dump functions."""
if current_app:
bp = current_app.blueprints.get(request.blueprint) if request else None
kwargs.setdefault(
'cls',
bp.json_encoder if bp and bp.json_encoder
else current_app.json_encoder
)
if not current_app.config['JSON_AS_ASCII']:
kwargs.setdefault('ensure_ascii', False)
kwargs.setdefault('sort_keys', current_app.config['JSON_SORT_KEYS'])
else:
kwargs.setdefault('sort_keys', True)
kwargs.setdefault('cls', JSONEncoder)
示例2: _dump_arg_defaults
# 需要導入模塊: from flask.globals import request [as 別名]
# 或者: from flask.globals.request import blueprint [as 別名]
def _dump_arg_defaults(kwargs, app=None):
"""Inject default arguments for dump functions."""
if app is None:
app = current_app
if app:
bp = app.blueprints.get(request.blueprint) if request else None
kwargs.setdefault(
'cls', bp.json_encoder if bp and bp.json_encoder else app.json_encoder
)
if not app.config['JSON_AS_ASCII']:
kwargs.setdefault('ensure_ascii', False)
kwargs.setdefault('sort_keys', app.config['JSON_SORT_KEYS'])
else:
kwargs.setdefault('sort_keys', True)
kwargs.setdefault('cls', JSONEncoder)
示例3: wrapped_preprocess_request
# 需要導入模塊: from flask.globals import request [as 別名]
# 或者: from flask.globals.request import blueprint [as 別名]
def wrapped_preprocess_request(self, wrapped, instance, args, kwargs):
tracked_request = getattr(request, "_scout_tracked_request", None)
if tracked_request is None:
return wrapped(*args, **kwargs)
# Unlike middleware in other frameworks, using request preprocessors is
# less common in Flask, so only add a span if there is any in use
have_before_request_funcs = (
None in instance.before_request_funcs
or request.blueprint in instance.before_request_funcs
)
if not have_before_request_funcs:
return wrapped(*args, **kwargs)
tracked_request.start_span("PreprocessRequest", should_capture_backtrace=False)
try:
return wrapped(*args, **kwargs)
finally:
tracked_request.stop_span()
示例4: _load_arg_defaults
# 需要導入模塊: from flask.globals import request [as 別名]
# 或者: from flask.globals.request import blueprint [as 別名]
def _load_arg_defaults(kwargs):
"""Inject default arguments for load functions."""
if current_app:
bp = current_app.blueprints.get(request.blueprint) if request else None
kwargs.setdefault(
'cls',
bp.json_decoder if bp and bp.json_decoder
else current_app.json_decoder
)
else:
kwargs.setdefault('cls', JSONDecoder)
示例5: _load_arg_defaults
# 需要導入模塊: from flask.globals import request [as 別名]
# 或者: from flask.globals.request import blueprint [as 別名]
def _load_arg_defaults(kwargs, app=None):
"""Inject default arguments for load functions."""
if app is None:
app = current_app
if app:
bp = app.blueprints.get(request.blueprint) if request else None
kwargs.setdefault(
'cls',
bp.json_decoder if bp and bp.json_decoder
else app.json_decoder
)
else:
kwargs.setdefault('cls', JSONDecoder)