本文整理汇总了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)