def redirect_ruri(req, *args): item = Redirect() item.src = req.uri_rule item.get(req, key='src') dst = item.dst.format(*args) print args redirect(req, dst, permanent=int(item.code == state.HTTP_MOVED_PERMANENTLY))
def test_add(self, req, redirect): item = Redirect() item.state = 1 assert isinstance(item.add(req), EmptySrc) item.src = '/' assert isinstance(item.add(req), EmptyDst) item.dst = '/root' assert isinstance(item.add(req), BadCode) item.code = 301 assert item.add(req) is None
def redirect_uri(req, *args): item = Redirect() item.src = req.uri item.get(req, key='src') redirect(req, item.dst, permanent=int(item.code == state.HTTP_MOVED_PERMANENTLY))