def init_db(app): try: from social.apps.flask_app import models from social.apps.flask_app.models import init_social social_storage = init_social(app, Base, db_session) except ImportError: # FIXME pass
app = Flask(__name__) app.config.from_object('flask_example.settings') app.config.from_object('flask_example.local_settings') # DB db = SQLAlchemy(app) db.metadata.bind = create_engine(app.config['SQLALCHEMY_DATABASE_URI']) engine = create_engine(app.config['SQLALCHEMY_DATABASE_URI'], convert_unicode=True) db_session = scoped_session(sessionmaker(bind=engine)) Base = declarative_base() Base.query = db_session.query_property() app.register_blueprint(social_auth) social_storage = init_social(app, Base) login_manager = login.LoginManager() login_manager.login_view = 'main' login_manager.login_message = '' login_manager.setup_app(app) from flask_example import models from flask_example import routes @login_manager.user_loader def load_user(userid): try: return models.user.User.query.get(int(userid)) except (TypeError, ValueError):
def init_db(app): from social.apps.flask_app import models from social.apps.flask_app.models import init_social social_storage = init_social(app, Base, db_session)
from social.apps.flask_app.routes import social_auth from social.apps.flask_app.models import init_social from social.apps.flask_app.template_filters import backends from flask.ext.sqlalchemy import SQLAlchemy from flask.ext.login import LoginManager, current_user, logout_user, UserMixin app = Flask(__name__) app.config.from_pyfile('config.py') app.register_blueprint(social_auth) login_manager = LoginManager() login_manager.init_app(app) db = SQLAlchemy(app) init_social(app, db) @app.before_request def set_g_user(): g.user = current_user._get_current_object() @login_manager.user_loader def load_user(userid): from models import User try: return User.query.get(int(userid)) except (TypeError, ValueError): pass
from flask import Flask from flask.ext.login import LoginManager from social.apps.flask_app.routes import social_auth from social.apps.flask_app.models import init_social from flask.ext.sqlalchemy import SQLAlchemy app = Flask(__name__) app.config.from_pyfile('../local.cfg', silent=True) app.config.from_pyfile('config.py') app.register_blueprint(social_auth) login_manager = LoginManager() login_manager.init_app(app) db = SQLAlchemy(app) init_social(app, db)
app.config.from_object('flask_example.local_settings') except ImportError: pass # DB db = SQLAlchemy(app) db.metadata.bind = create_engine(app.config['SQLALCHEMY_DATABASE_URI']) engine = create_engine(app.config['SQLALCHEMY_DATABASE_URI'], convert_unicode=True) session = scoped_session(sessionmaker(bind=engine)) Base = declarative_base() Base.query = session.query_property() app.register_blueprint(social_auth) social_storage = init_social(app, Base, session) login_manager = login.LoginManager() login_manager.login_view = 'main' login_manager.login_message = '' login_manager.setup_app(app) from flask_example import models from flask_example import routes @login_manager.user_loader def load_user(userid): try: return models.user.User.query.get(int(userid)) except (TypeError, ValueError):
from social.apps.flask_app.routes import social_auth from social.apps.flask_app.models import init_social from social.apps.flask_app.template_filters import backends # App app = Flask(__name__) app.config.from_object('example.settings') app.config.from_object('example.local_settings') # DB db = SQLAlchemy(app) db.metadata.bind = create_engine(app.config['SQLALCHEMY_DATABASE_URI']) app.register_blueprint(social_auth) social_storage = init_social(app, db) login_manager = login.LoginManager() login_manager.login_view = 'main' login_manager.login_message = '' login_manager.setup_app(app) from example import models from example import routes @login_manager.user_loader def load_user(userid): try: return models.user.User.query.get(int(userid)) except (TypeError, ValueError):