-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
36 lines (26 loc) · 1.03 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'''
app.py is only used to support flask commands
develop execution from run.py; production execution from rrwebapp.wsgi
'''
# standard
import os.path
# pypi
from flask_migrate import Migrate
from sqlalchemy.orm import scoped_session, sessionmaker
# homegrown
from rrwebapp import create_app
from rrwebapp.settings import Production, get_configfiles
from rrwebapp.model import db
from rrwebapp.applogging import setlogging
configfiles = get_configfiles()
# init_for_operation=False because when we create app this would use database and cause
# sqlalchemy.exc.OperationalError if one of the updating tables needs migration
app = create_app(Production(configfiles), configfiles, init_for_operation=False)
# set up scoped session
with app.app_context():
# this causes SQLALCHEMY_BINDS not to work ('user' bind missing)
# db.session = scoped_session(sessionmaker(autocommit=False, autoflush=False, bind=db.engine))
# db.query = db.session.query_property()
# turn on logging
setlogging()
migrate = Migrate(app, db, compare_type=True)