Python django.views.decorators.http 模块,require_http_methods() 实例源码

我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用django.views.decorators.http.require_http_methods()

项目:django-express    作者:bluekvirus    | 项目源码 | 文件源码
def methods(*args):
    """
    1. Ensures only limited HTTP methods are supported. (for served models)
    2. Register service function with only certain method on given @url
    """
    def decorator(funcOrModel):
        if type(funcOrModel) is DjangoModel:
            funcOrModel._express_dispatcher = require_http_methods(args)(funcOrModel._express_dispatcher)
        else:
            funcOrModel._methods = args  # this will be used later upon autodiscover() for creating service dispatcher (per url).
        return funcOrModel
    return decorator