I am working on a project using web.py framework. I have a small code for redirecting a user to a different screen if the result returned from a database query is blank (or number of rows returned is zero).
voma_user_details = get_user_by_email(['id','is_active'],None,email)
if len(list(voma_user_details)) == 0:
#return redirect_url+'?error=User not found in database'
web.redirect(redirect_url+'?error=User not found in database')
voma_id = int(voma_user_details[0]['id'])
Here when the query returns zero records, the page should be redirected to redirect_url, however the redirect does not work and it raises an exception on the next line i.e. list index out of range (as the list length is zero). I checked by printing the redirect url in the if block, it goes into the block but does not redirect the page.
Any pointers will be highly appreciated.