Well, you just need to pass them as an argument to render_template, perhaps the most common use of this involves passing a list of dictionaries as an argument to render the template:
def Viewfunction(): #do something, get something from db as result and then arguments = [dict(name=row[0],age=row[1]) for row in result.fetchall()] return render_template('mytemplate.html', form=myform, arguments=arguments)
and then access them as follows:
{% for item in arguments %} {{ item.name }} {{ item.age }} {% endfor %}
Obviously, you can also transfer all other lists, and not just lists of dictionaries into a template, you alternate them with them very similarly.
Regarding debugging, I found that Flask built into debugging tools is very useful, if you get an exception, you just get a page where you can execute code, if you are interested in all your variables, you can just type locals () into one from frames inside stacktrace. You just need to enable debugging mode to use it, just remember to turn it off during production.
Here's a working example, taken from the flaskr sample application included in the flask when you load it into the examples folder:
@app.route('/') def show_entries(): db = get_db() cur = db.execute('select title, text from entries order by id desc') entries = cur.fetchall() return render_template('show_entries.html', entries=entries,local=locals())
When you do:
{% for item in local %} {{ item }} {% endfor %}
you get db cur entries, is that what you want?