From dccef26263ba98c47fc5f8121a074a34b012ba89 Mon Sep 17 00:00:00 2001 From: Elrond Date: Sun, 17 Jul 2011 16:09:22 +0200 Subject: [PATCH] Move setting up of storage into init/__init__.py Factoring out this one should be the last one needed to rewrite the celery setup. The idea is to not setup the whole app, but just call a bunch of individual setup_* functions and be done. --- mediagoblin/app.py | 15 +++++---------- mediagoblin/init/__init__.py | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/mediagoblin/app.py b/mediagoblin/app.py index 85c3c0c7..58db4e8d 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -20,11 +20,12 @@ import urllib import routes from webob import Request, exc -from mediagoblin import routing, util, storage +from mediagoblin import routing, util from mediagoblin.mg_globals import setup_globals from mediagoblin.init.celery import setup_celery_from_config from mediagoblin.init import get_jinja_loader, get_staticdirector, \ - setup_global_and_app_config, setup_workbench, setup_database + setup_global_and_app_config, setup_workbench, setup_database, \ + setup_storage class MediaGoblinApp(object): @@ -62,10 +63,7 @@ class MediaGoblinApp(object): app_config.get('user_template_path')) # Set up storage systems - self.public_store = storage.storage_system_from_config( - app_config, 'publicstore') - self.queue_store = storage.storage_system_from_config( - app_config, 'queuestore') + self.public_store, self.queue_store = setup_storage() # set up routing self.routing = routing.get_mapper() @@ -90,10 +88,7 @@ class MediaGoblinApp(object): # object. ####################################################### - setup_globals( - app=self, - public_store=self.public_store, - queue_store=self.queue_store) + setup_globals(app = self) # Workbench *currently* only used by celery, so this only # matters in always eager mode :) diff --git a/mediagoblin/init/__init__.py b/mediagoblin/init/__init__.py index 1e519cc9..64fa9b92 100644 --- a/mediagoblin/init/__init__.py +++ b/mediagoblin/init/__init__.py @@ -23,6 +23,7 @@ from mediagoblin.mg_globals import setup_globals from mediagoblin.db.open import setup_connection_and_db_from_config from mediagoblin.db.util import MigrationManager from mediagoblin.workbench import WorkbenchManager +from mediagoblin.storage import storage_system_from_config class Error(Exception): pass @@ -103,6 +104,19 @@ def get_staticdirector(app_config): "direct_remote_paths must be provided") +def setup_storage(): + app_config = mg_globals.app_config + + public_store = storage_system_from_config(app_config, 'publicstore') + queue_store = storage_system_from_config(app_config, 'queuestore') + + setup_globals( + public_store = public_store, + queue_store = queue_store) + + return public_store, queue_store + + def setup_workbench(): app_config = mg_globals.app_config -- 2.25.1