Esempio n. 1
0
def main(argv=sys.argv):
    if len(argv) < 2:
        usage(argv)
    config_uri = argv[1]
    options = parse_vars(argv[2:])
    setup_logging(config_uri)
    settings = get_appsettings(config_uri, options=options)
    init_social(get_settings(app_settings), Base, DBSession)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)
Esempio n. 2
0
def get_user(request):
    user_id = request.session.get("user_id")
    if user_id:
        user = DBSession.query(User).filter(User.id == user_id).first()
    else:
        user = None
    return user
Esempio n. 3
0
def get_user(request):
    user_id = request.session.get('user_id')
    if user_id:
        user = DBSession.query(User)\
                        .filter(User.id == user_id)\
                        .first()
    else:
        user = None
    return user