Skip to content
Myr

Minor tutorial documentation fixes (grammar, etc)

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

authored by Adam Zapletal · committed by Armin Ronacher · parent 87c2c79 · Browse files · 2 files+16 added−16 removed
This commit

State

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

Diff stats

2 files+16 added−16 removed

  • other:+16 added−16 removed

2 files+16 added−16 removed

modified:docs/tutorial/setup.rst+2 added-2 removed
50 unmodified lines
51The `secret_key` is needed to keep the client-side sessions secure.52Choose that key wisely and as hard to guess and complex as possible. The53debug flag enables or disables the interactive debugger. Never leave54debug mode activated in a production system because it will allow users to55executed code on the server!55execute code on the server!5657We also add a method to easily connect to the database specified. That58can be used to open a connection on request and also from the interactive59Python shell or a script. This will come in handy later
3 unmodified lines
63 def connect_db():64 return sqlite3.connect(app.config['DATABASE'])6566Finally we just add a line to the bottom of the file that fires up the67server if we run that file as standalone application::67server if we want to run that file as a standalone application::6869 if __name__ == '__main__':70 app.run()71
12 unmodified lines
modified:docs/tutorial/views.rst+14 added-14 removed
9 unmodified lines
10------------1112This view shows all the entries stored in the database. It listens on the13root of the application and will select title and text from the database.14The one with the highest id (the newest entry) on top. The rows returned15from the cursor are tuples with the columns ordered like specified in the16select statement. This is good enough for small applications like here,17but you might want to convert them into a dict. If you are interested how18to do that, check out the :ref:`easy-querying` example.14The one with the highest id (the newest entry) will be on top. The rows15returned from the cursor are tuples with the columns ordered like specified16in the select statement. This is good enough for small applications like17here, but you might want to convert them into a dict. If you are18interested in how to do that, check out the :ref:`easy-querying` example.1920The view function will pass the entries as dicts to the21`show_entries.html` template and return the rendered one::22
29 unmodified lines
52----------------5354These functions are used to sign the user in and out. Login checks the55username and password against the ones from the configuration and sets the56`logged_in` key in the session. If the user logged in successfully that57key is set to `True` and the user is redirected back to the `show_entries`58page. In that case also a message is flashed that informs the user he or59she was logged in successfully. If an error occoured the template is60notified about that and the user asked again::56`logged_in` key in the session. If the user logged in successfully, that57key is set to `True`, and the user is redirected back to the `show_entries`58page. In addition, a message is flashed that informs the user that he or59she was logged in successfully. If an error occurred, the template is60notified about that, and the user is asked again::6162 @app.route('/login', methods=['GET', 'POST'])63 def login():64 error = None
7 unmodified lines
72 flash('You were logged in')73 return redirect(url_for('show_entries'))74 return render_template('login.html', error=error)7576The logout function on the other hand removes that key from the session76The logout function, on the other hand, removes that key from the session77again. We use a neat trick here: if you use the :meth:`~dict.pop` method78of the dict and pass a second parameter to it (the default) the method78of the dict and pass a second parameter to it (the default), the method79will delete the key from the dictionary if present or do nothing when that80key was not in there. This is helpful because we don't have to check in81that case if the user was logged in.80key is not in there. This is helpful because now we don't have to check81if the user was logged in.8283::8485 @app.route('/logout')
6 unmodified lines