def track_logout(sender, user, **extra): session = DBSession() user.active = False session.add(user) session.commit()
def track_login(sender, user, **extra): session = DBSession() user.active = True session.add(user) session.commit()
def add(cls, account, password): session = DBSession() user = cls(account=account, active=False) user.hash_password(password) session.add(user) session.flush()
def get_account(cls, account): return DBSession().query(cls).filter(cls.account == account).first()
def get_user_by_id(cls, user_id): return DBSession().query(cls).filter(cls.id == user_id).first()
def add_blog(cls, topic, genre, content): session = DBSession() blog = cls(topic=topic, genre=genre, content=content) session.add(blog) session.flush()