Skip to content
Myr

Made it explicitly clear where changes should go in the tutorial

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sven-Hendrik Haase · committed by Sven-Hendrik Haase · parent 0787872 · Browse files · 1 file+5 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+5 added−2 removed

  • other:+5 added−2 removed

1 file+5 added−2 removed

modified:docs/tutorial/dbinit.rst+5 added-2 removed
21 unmodified lines
2223If you want to do that, you first have to import the24:func:`contextlib.closing` function from the contextlib package. If you25want to use Python 2.5 it's also necessary to enable the `with` statement26first (`__future__` imports must be the very first import)::26first (`__future__` imports must be the very first import). Accordingly,27the following lines should be to your existing import lines in28`flaskr.py`::2930 from __future__ import with_statement31 from contextlib import closing3233Next we can create a function called `init_db` that initializes the34database. For this we can use the `connect_db` function we defined33earlier. Just add that function below the `connect_db` function::35earlier. Just add that function below the `connect_db` function in36`flask.py`::3738 def init_db():39 with closing(connect_db()) as db:40 with app.open_resource('schema.sql') as f:
30 unmodified lines