<s> from flask . ext . sqlalchemy import SQLAlchemy <EOL> from flask . ext . login import UserMixin , AnonymousUserMixin <EOL> from werkzeug . security import generate_password_hash , check_password_hash <EOL> db = SQLAlchemy ( ) <EOL> class User ( db . Model , UserMixin ) : <EOL> id = db . Column ( db . Integer ( ) , primary_key = True ) <EOL> username = db . Column ( db . String ( ) ) <EOL> password = db . Column ( db . String ( ) ) <EOL> def __init__ ( self , username , password ) : <EOL> self . username = username <EOL> self . set_password ( password ) <EOL> def set_password ( self , password ) : <EOL> self . password = generate_password_hash ( password ) <EOL> def check_password ( self , value ) : <EOL> return check_password_hash ( self . password , value ) <EOL> def is_authenticated ( self ) : <EOL> if isinstance ( self , AnonymousUserMixin ) : <EOL> return False <EOL> else : <EOL> return True <EOL> def is_active ( self ) : <EOL> return True <EOL> def is_anonymous ( self ) : <EOL> if isinstance ( self , AnonymousUserMixin ) : <EOL> return True <EOL> else : <EOL> return False <EOL> def get_id ( self ) : <EOL> return self . id <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % self . username </s>
