def default(self, sendby=None): if sendby == 'forward': forward('AppLevelView') assert False if sendby == 'redirect': redirect('/applevelview/foo') assert False if sendby == 'rdp': redirect('/applevelview/foo', permanent=True) if sendby == '303': redirect('/applevelview/foo', code=303) return 'news index'
def send_to_index(sender, endpoint, urlargs): """ simulating hijacking the request and forcing it to go to another view. This minicks what you would want to do if a user need to change a password, was locked out, or any number of things that might cause you to want to send them to a different location than the one they are requesting. """ if 'request-hijack/forward' in rg.request.url: # we have to have a flag that says we have already forwarded, otherwise # we will get a forward loop since the request isn't modified # when we forward if getattr(rg, 'newlayout_events_send_to_index', None): return rg.newlayout_events_send_to_index = True forward('Index', tname='index') elif 'request-hijack/redirect' in rg.request.url: redirect('/index/index')
def send_to_index(sender, endpoint, urlargs): """ simulating hijacking the request and forcing it to go to another view. This minicks what you would want to do if a user need to change a password, was locked out, or any number of things that might cause you to want to send them to a different location than the one they are requesting. """ if 'request-hijack/forward' in rg.request.url: # we have to have a flag that says we have already forwarded, otherwise # we will get a forward loop since the request isn't modified # when we forward if getattr(rg, 'newlayout_events_send_to_index', None): return rg.newlayout_events_send_to_index = True forward('Index', tname='index') elif 'request-hijack/redirect' in rg.request.url: redirect('index/index')
def default(self): forward('tests:ForwardTo')
def default(self): forward('tests:ForwardLoop')
def check_reset_required(sender, endpoint, urlargs): skip_endpoints = ['auth:ChangePassword', 'auth:Logout'] if user.is_authenticated and user.reset_required and endpoint not in skip_endpoints: forward('auth:ChangePassword')
def page1(): forward('page2') return 'hello nosession!'
def default(self, sendby=None): forward('AppLevelView', v1='a', v2='b')