def test_initialize_data_does_not_reset_timestamp(self): # initialize_data() has already been called, so the database is # initialized and the 'site configuration changed' Timestamp has # been set. Calling initialize_data() again won't change the # date on the timestamp. timestamp = get_one( self._db, Timestamp, collection=None, service=Configuration.SITE_CONFIGURATION_CHANGED, ) old_timestamp = timestamp.finish SessionManager.initialize_data(self._db) assert old_timestamp == timestamp.finish
def initialize_database(autoinitialize=True): testing = 'TESTING' in os.environ db_url = Configuration.database_url(testing) if autoinitialize: SessionManager.initialize(db_url) session_factory = SessionManager.sessionmaker(db_url) _db = flask_scoped_session(session_factory, app) app._db = _db if autoinitialize: SessionManager.initialize_data(_db) log_level = LogConfiguration.initialize(_db, testing=testing) debug = log_level == 'DEBUG' app.config['DEBUG'] = debug app.debug = debug _db.commit() logging.getLogger().info("Application debug mode==%r" % app.debug)
from core.util import LanguageCodes from flask.ext.babel import Babel app = Flask(__name__) testing = 'TESTING' in os.environ db_url = Configuration.database_url(testing) # Initialize a new database session unless we were told not to # (e.g. because a script already initialized it). autoinitialize = os.environ.get('AUTOINITIALIZE') != 'False' if autoinitialize: SessionManager.initialize(db_url) session_factory = SessionManager.sessionmaker(db_url) _db = flask_scoped_session(session_factory, app) if autoinitialize: SessionManager.initialize_data(_db) app.config['BABEL_DEFAULT_LOCALE'] = LanguageCodes.three_to_two[ Configuration.localization_languages()[0]] app.config['BABEL_TRANSLATION_DIRECTORIES'] = "../translations" babel = Babel(app) import routes import admin.routes log_level = LogConfiguration.initialize(_db, testing=testing) debug = log_level == 'DEBUG' logging.getLogger().info("Application debug mode==%r" % debug) app.config['DEBUG'] = debug app.debug = debug
) from flask_sqlalchemy_session import flask_scoped_session from sqlalchemy.orm import sessionmaker from config import Configuration from core.model import SessionManager from core.util import LanguageCodes from flask.ext.babel import Babel app = Flask(__name__) testing = 'TESTING' in os.environ db_url = Configuration.database_url(testing) SessionManager.initialize(db_url) session_factory = SessionManager.sessionmaker(db_url) _db = flask_scoped_session(session_factory, app) SessionManager.initialize_data(_db) app.config['BABEL_DEFAULT_LOCALE'] = LanguageCodes.three_to_two[Configuration.localization_languages()[0]] app.config['BABEL_TRANSLATION_DIRECTORIES'] = "../translations" babel = Babel(app) import routes if Configuration.get(Configuration.INCLUDE_ADMIN_INTERFACE): import admin.routes debug = Configuration.logging_policy().get("level") == 'DEBUG' logging.getLogger().info("Application debug mode==%r" % debug) app.config['DEBUG'] = debug app.debug = debug def run():