code: def lazy_raise_or_redirect():
      '''
      Raise exception lazily to ensure request.endpoint is set
      Also perform redirect if needed
      '''
      if not request.view_args:
          return
      for name, value in request.view_args.items():
          if isinstance(value, NotFound):
              request.routing_exception = value
              break
          elif isinstance(value, LazyRedirect):
              new_args = request.view_args
              new_args[name] = value.arg
              new_url = url_for(request.endpoint, **new_args)
              return redirect(new_urlf lazy_raise_or_redirect():
      '''
      Raise exception lazily to ensure request.endpoint is set
      Also perform redirect if needed
      '''
      if not request.view_args:
          return
      for name, value in request.view_args.items():
          if isinstance(value, NotFound):
              request.routing_exception = value
              break
          elif isinstance(value, LazyRedirect):
              new_args = request.view_args
              new_args[name] = value.arg
              new_url = url_for(request.endpoint, **new_args)
              return redirect(new_url)
docs: Raise exception lazily to ensure request.endpoint is set
      Also perform redirect if needed