Esempio n. 1
0
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))
Esempio n. 2
0
 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
Esempio n. 3
0
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))