decorators.py 文件源码

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

项目:weixin_server 作者: duoduo369 项目源码 文件源码
def require_config(config_model):
    """View decorator that enables/disables a view based on configuration.

    Arguments:
        config_model (ConfigurationModel subclass): The class of the configuration
            model to check.

    Returns:
        HttpResponse: 404 if the configuration model is disabled,
            otherwise returns the response from the decorated view.

    """
    def _decorator(func):
        @wraps(func)
        def _inner(*args, **kwargs):
            if not config_model.current().enabled:
                return HttpResponseNotFound()
            else:
                return func(*args, **kwargs)
        return _inner
    return _decorator
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号