当前位置: 首页>>代码示例>>Python>>正文


Python Response.location方法代码示例

本文整理汇总了Python中webob.response.Response.location方法的典型用法代码示例。如果您正苦于以下问题:Python Response.location方法的具体用法?Python Response.location怎么用?Python Response.location使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在webob.response.Response的用法示例。


在下文中一共展示了Response.location方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_location

# 需要导入模块: from webob.response import Response [as 别名]
# 或者: from webob.response.Response import location [as 别名]
def test_location():
    res = Response()
    res.location = '/test.html'
    eq_(res.location, '/test.html')
    req = Request.blank('/')
    eq_(req.get_response(res).location, 'http://localhost/test.html')
    res.location = '/test2.html'
    eq_(req.get_response(res).location, 'http://localhost/test2.html')
开发者ID:perey,项目名称:webob,代码行数:10,代码来源:test_response.py

示例2: test_location

# 需要导入模块: from webob.response import Response [as 别名]
# 或者: from webob.response.Response import location [as 别名]
def test_location():
    res = Response()
    res.location = '/test.html'
    assert res.location == '/test.html'
    req = Request.blank('/')
    assert req.get_response(res).location == 'http://localhost/test.html'
    res.location = '/test2.html'
    assert req.get_response(res).location == 'http://localhost/test2.html'
开发者ID:doulbekill,项目名称:webob,代码行数:10,代码来源:test_response.py

示例3: test_location

# 需要导入模块: from webob.response import Response [as 别名]
# 或者: from webob.response.Response import location [as 别名]
def test_location():
    res = Response()
    res.status = "301"
    res.location = "/test.html"
    assert res.location == "/test.html"
    req = Request.blank("/")
    assert req.get_response(res).location == "http://localhost/test.html"
    res.location = "/test2.html"
    assert req.get_response(res).location == "http://localhost/test2.html"
开发者ID:Pylons,项目名称:webob,代码行数:11,代码来源:test_response.py

示例4: __call__

# 需要导入模块: from webob.response import Response [as 别名]
# 或者: from webob.response.Response import location [as 别名]
    def __call__(self, req):
        results = self.map.routematch(environ=req.environ)
        if not results:
            return exc.HTTPNotFound()

        match, route = results
        link = URLGenerator(self.map, req.environ)

        if route.redirect:
            # Taken from the routes middleware module
            route_name = '_redirect_%s' % id(route)
            location = link(route_name, **match)

            # Build the response manually so we don't have to try to map the
            # route status to a specific webob exception
            redirect_response = Response(status=route.redirect_status)
            redirect_response.location = location

            return redirect_response

        match_controller = match.get('controller', None)

        if not callable(match_controller):
            log.error('Unsupported route match: %s', match)
            return exc.HTTPNotFound()

        req.urlvars = ((), match)
        req.link = link
        controller = match_controller(req, **self.config)
        return controller()
开发者ID:jd-boyd,项目名称:corker,代码行数:32,代码来源:app.py

示例5: test_location_unicode

# 需要导入模块: from webob.response import Response [as 别名]
# 或者: from webob.response.Response import location [as 别名]
def test_location_unicode():
    environ = {
        "REQUEST_METHOD": "GET",
        "wsgi.url_scheme": "http",
        "HTTP_HOST": u"test.com",
    }
    res = Response()
    res.status = "301"
    res.location = "/test.html"

    def start_response(status, headerlist):
        for (header, val) in headerlist:
            if header.lower() == "location":
                assert val == "http://test.com/test.html"
                assert isinstance(val, str)

    res(environ, start_response)
开发者ID:Pylons,项目名称:webob,代码行数:19,代码来源:test_response.py


注:本文中的webob.response.Response.location方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。