# -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 ############################################################################### # ScribeEngine - Open Source Blog Software # # --------------------------------------------------------------------------- # # Copyright (c) 2010-2017 Raoul Snyman # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # # Software Foundation; version 2 of the License. # # # # This program is distributed in the hope that it will be useful, but WITHOUT # # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # # more details. # # # # You should have received a copy of the GNU General Public License along # # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ The :mod:`~scribeengine` module sets up and runs ScribeEngine """ import os from flask import Flask from flask_mail import Mail from flask_themes import setup_themes from flask_user import SQLAlchemyAdapter, UserManager from scribeengine.config import read_config_from_file from scribeengine.db import db from scribeengine.models import User def create_app(config_file=None): """ Create the application object """ application = Flask('ScribeEngine') # Set up configuration if not config_file: if os.environ.get('SCRIBEENGINE_CONFIG'): config_file = os.environ['SCRIBEENGINE_CONFIG'] elif os.path.exists('sundaybuilder.conf'): config_file = 'sundaybuilder.conf' if config_file: application.config.update(read_config_from_file(config_file)) # Set up mail, themes Mail(application) setup_themes(application, app_identifier='ScribeEngine') # Set up database db.init_app(application) db.create_all() # Setup Flask-User db_adapter = SQLAlchemyAdapter(db, User) # Register the User model user_manager = UserManager(db_adapter, application) # Initialize Flask-User # Register all the blueprints # Return the application object return application