Python django.utils.decorators 模块,decorator_from_middleware() 实例源码

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

项目:site    作者:alphageek-xyz    | 项目源码 | 文件源码
def test_with_extra_meta(self):
        req = self.rf.get('/')
        for f in getattr(
            MultipleProxyMiddleware,
            'FORWARDED_FOR_FIELDS'
        ): req.META[f] = 'Value1'
        del(req.META['HTTP_X_FORWARDED_SERVER'])
        req.META['HTTP_X_FORWARDED_FOR'] += ',Foo'
        req.META['SERVER_SOFTWARE'] = 'foo/1.1'
        viawrap = decorator_from_middleware(ViaHeaderMiddleware)
        mulwrap = decorator_from_middleware(MultipleProxyMiddleware)
        viawrap(mulwrap(goodview))(req)
项目:site    作者:alphageek-xyz    | 项目源码 | 文件源码
def via_header(view_func):
    return decorator_from_middleware(
        import_string('headers.middleware.ViaHeaderMiddleware')
    )(view_func)