def setUpClass(cls): db.create_all() db.session.add( Repo(created_at=datetime.now(), description='test', full_name='test/test', html_url='http://py.test', id=1, name='test')) db.session.commit()
def setUpClass(cls): db.create_all()
return session.get('github_token') @app.before_request def user_load_from_session(): ignored = ['/logout'] if str(request.url_rule) in ignored: return None g.user = User.query.get(session['user_id']) if 'user_id' in session else None def user_get_or_create(uemail, uid, uname): entity = User.query.filter_by(email=uemail).first() if entity: return entity entity = User(email=uemail, github_id=uid, username=uname) db.session.add(entity) db.session.commit() return entity def url_next(): return request.args.get('next') or request.referrer or None if __name__ == '__main__': app.run(host='0.0.0.0') db.create_all() # @todo remove it