Added a load_user function to views.py.
This callback will be used by Flask-Login and it loads a user from the DB.
User IDs in Flask-Login are always unicode strings, hence the need to convert to int.
Made changes to the views.py file again.
Imported a shit ton of modules.
The 'g' global object is setup by Flask to store and share data during the life of a request. The logged in user is stored here.
The url_for function is defined by Flask as a clean way to obtain the URL for a given view function. Let Flask do the URL building.
The flask session object differs from the db.session object. Once data is stored in this object, it is available during that request and any future requests from the *same client*. Data remains until explicitly removed. Flask keeps a different session file for each client of the app.
oid.try_login call triggers user auth via Flask-OpenID. It takes the openid given by the user and a list of items we require from the OpenID provider (nickname and email here).
OpenID auth happens asynchronously. Flask-OpenID calls a function registered with @oid.after_login decorator if auth is successful. If not, user is taken back to the login page.