本文整理汇总了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')
示例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'
示例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"
示例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()
示例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)