Attach the MediaGoblinApp to the engine, and provide a way for models to access
This allows SQLAlchemy models to gain access to app-level configuration without the need for global variables. This commit sponsored by Peter Hogg. Thank you, Peter!
This commit is contained in:
@@ -60,14 +60,16 @@ def setup_global_and_app_config(config_path):
|
||||
return global_config, app_config
|
||||
|
||||
|
||||
def setup_database(run_migrations=False):
|
||||
app_config = mg_globals.app_config
|
||||
global_config = mg_globals.global_config
|
||||
def setup_database(app):
|
||||
app_config = app.app_config
|
||||
global_config = app.global_config
|
||||
run_migrations = app_config['run_migrations']
|
||||
|
||||
# Load all models for media types (plugins, ...)
|
||||
load_models(app_config)
|
||||
# Set up the database
|
||||
db = setup_connection_and_db_from_config(app_config, run_migrations)
|
||||
db = setup_connection_and_db_from_config(
|
||||
app_config, run_migrations, app=app)
|
||||
if run_migrations:
|
||||
#Run the migrations to initialize/update the database.
|
||||
from mediagoblin.gmg_commands.dbupdate import run_all_migrations
|
||||
|
||||
Reference in New Issue
Block a user