def _whitelist_standard_flask_kwargs(cls, kwargs):
"""Whitelist a dictionary of kwargs to remove any that are not valid
for Flask's ``__init__`` constructor.
Since many Fleaker app mixins define their own kwargs for use in
construction and Flask itself does not accept ``**kwargs``, we need to
whitelist anything unknown.
Uses the proper argspec from the :meth:`flask.Flask.__init__` so it
should handle all args.
Args:
kwargs (dict): The dictionary of kwargs you want to whitelist.
Returns:
dict: The whitelisted dictionary of kwargs.
"""
# prevent any copy shenanigans from happening
kwargs = deepcopy(kwargs)
if not cls._flask_init_argspec_cache:
cls._flask_init_argspec_cache = inspect.getargspec(Flask.__init__)
return {key: val for key, val in iteritems(kwargs)
if key in cls._flask_init_argspec_cache.args}
评论列表
文章目录