9. The resolve_alias View
- The resolve_alias view is shown below.
- Line 1 is the beginning of a python
for
loop. Web2py templates delimit python code with {{}}
. The resolve_alias
function passed a rows
object to the view. We loop through the rows
objects. - Line 2 uses the
redirect
function to route the user to the URL found in row.the_url
- Line 3 The
pass
function closes the for
loop and is necessary when writing Python code in templates as the indentations are not significant in this context.
##### Copy the code below and paste it into default/resolve_alias.html #####
{{for row in rows:}}
{{redirect(row.the_url)}}
{{pass}}
[ Previous ] [ Next ]