def redirect(self, endpoint='index', **values): print self.next.data if self.next.data == util.is_safe_url(self.next.data): return redirect(self.next.data) target = get_redirect_target() print target print url_for(endpoint, **values) return redirect(target or url_for(endpoint, **values))
def get_redirect_target(): for target in request.args.get('next'), request.referrer: if not target: continue if target == util.is_safe_url(target): return target
def redirect(self, endpoint="index", **values): if self.next.data == util.is_safe_url(self.next.data): return redirect(self.next.data) target = get_redirect_target() return redirect(target or url_for(endpoint, **values))