Previous topic

base.tests module

Next topic

info package

This Page

base.views module

The most common views for the whole project.

This makes use of flask’s [pluggable views](http://flask.pocoo.org/docs/views/)

copyright:(c) 2012 by Roman Semirook.
license:BSD, see LICENSE for more details.
class base.views.FrontView[source]

Bases: flask.views.MethodView

Tha application front page.

Just renders the template templates/base/main.html

get()[source]
methods = ['GET']
class base.views.LoginView[source]

Bases: flask.views.MethodView

get()[source]

Handles the HTTP GET requests (overriding MethodView.get()) . :return: The rendered login form page.

methods = ['GET', 'POST']
post()[source]

Handles the HTTP POST requests (overriding MethodView.post()) .

If the form was correctly filled and the user password validates (through check_password()), calls flask.ext.login.login_user(), emits a flash message of success and redirects the request to the next parameter or the home page if not specified.

Otherwise, emits errors as flash messages and renders the login page again.

Returns:On error, renders the login page, but redirects to value of next or home page on success.
base.views.load_user(user_id)[source]

We need to provide a user_loader() callback to the login manager. This callback is used to reload the user object from the user ID stored in the session.

It should return None (not raise an exception) if the ID is not valid. (In that case, the ID will manually be removed from the session and processing will continue.)

This is done by calling get_by_id()) , :param user_id: the unicode ID of a user :return:the corresponding user object

base.views.logout(*args, **kwargs)[source]

calls func:flask.ext.login.logout_user, and redirects to home page.

Returns:redirects to home page