46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
import logging
|
|
import os
|
|
|
|
from flask import Flask
|
|
from flask.ext.principal import Principal
|
|
from flask.ext.login import LoginManager
|
|
from flask.ext.mail import Mail
|
|
|
|
import features
|
|
|
|
from storage import Storage
|
|
from data.userfiles import Userfiles
|
|
from util.analytics import Analytics
|
|
from data.billing import Billing
|
|
|
|
|
|
OVERRIDE_CONFIG_FILENAME = 'conf/stack/config.py'
|
|
|
|
|
|
app = Flask(__name__)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
if 'TEST' in os.environ:
|
|
from test.testconfig import TestConfig
|
|
logger.debug('Loading test config.')
|
|
app.config.from_object(TestConfig())
|
|
else:
|
|
from config import DefaultConfig
|
|
logger.debug('Loading default config.')
|
|
app.config.from_object(DefaultConfig())
|
|
|
|
if os.path.exists(OVERRIDE_CONFIG_FILENAME):
|
|
logger.debug('Applying config file: %s', OVERRIDE_CONFIG_FILENAME)
|
|
app.config.from_pyfile(OVERRIDE_CONFIG_FILENAME)
|
|
|
|
features.import_features(app.config)
|
|
|
|
Principal(app, use_sessions=False)
|
|
|
|
login_manager = LoginManager(app)
|
|
mail = Mail(app)
|
|
storage = Storage(app)
|
|
userfiles = Userfiles(app)
|
|
analytics = Analytics(app)
|
|
billing = Billing(app)
|