import logging import os import stripe 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 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() login_manager.init_app(app) mail = Mail() mail.init_app(app) storage = Storage() storage.init_app(app) userfiles = Userfiles() userfiles.init_app(app) stripe.api_key = app.config.get('STRIPE_SECRET_KEY', None) analytics = Analytics() analytics.init_app(app)