base.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:fleaker 作者: croscon 项目源码 文件源码
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}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号