aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2011-06-18 18:59:42 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2011-06-18 18:59:42 -0500
commit924c586b72a2313029cc9b8529504060b30e5c55 (patch)
treeaa6445ed5e498f9115b0b5ec98f16180e0af92b2
parent52f20ff33715225d45aead9678701915f3e32706 (diff)
downloadmediagoblin-924c586b72a2313029cc9b8529504060b30e5c55.tar.lz
mediagoblin-924c586b72a2313029cc9b8529504060b30e5c55.tar.xz
mediagoblin-924c586b72a2313029cc9b8529504060b30e5c55.zip
Updating celery_setup.from_celery to use new config loading / app init
- The code for this is significantly simpler now. The app sets up everything but celery, and from_celery finishes the job. - There's no more specifying the mediagoblin section in the file, which doesn't make sense anymore and was already confusing.
-rw-r--r--mediagoblin/celery_setup/from_celery.py66
1 files changed, 12 insertions, 54 deletions
diff --git a/mediagoblin/celery_setup/from_celery.py b/mediagoblin/celery_setup/from_celery.py
index c8ccebc8..45e65e52 100644
--- a/mediagoblin/celery_setup/from_celery.py
+++ b/mediagoblin/celery_setup/from_celery.py
@@ -16,14 +16,8 @@
import os
-from paste.deploy.loadwsgi import NicerConfigParser
-from paste.deploy.converters import asbool
-
-from mediagoblin import storage
-from mediagoblin.db.open import setup_connection_and_db_from_config
+from mediagoblin import app, mg_globals
from mediagoblin.celery_setup import setup_celery_from_config
-from mediagoblin.mg_globals import setup_globals
-from mediagoblin.workbench import WorkbenchManager, DEFAULT_WORKBENCH_DIR
OUR_MODULENAME = __name__
@@ -33,64 +27,28 @@ def setup_self():
"""
Transform this module into a celery config module by reading the
mediagoblin config file. Set the environment variable
- MEDIAGOBLIN_CONFIG to specify where this config file is at and
- what section it uses.
-
- By default it defaults to 'mediagoblin.ini:app:mediagoblin'.
+ MEDIAGOBLIN_CONFIG to specify where this config file is.
- The first colon ":" is a delimiter between the filename and the
- config section, so in this case the filename is 'mediagoblin.ini'
- and the section where mediagoblin is defined is 'app:mediagoblin'.
+ By default it defaults to 'mediagoblin.ini'.
- Args:
- - 'setup_globals_func': this is for testing purposes only. Don't
- set this!
+ Note that if celery_setup_elsewhere is set in your config file,
+ this simply won't work.
"""
- mgoblin_conf_file, mgoblin_section = os.environ.get(
- 'MEDIAGOBLIN_CONFIG', 'mediagoblin.ini:app:mediagoblin').split(':', 1)
+ mgoblin_conf_file = os.path.abspath(
+ os.environ.get('MEDIAGOBLIN_CONFIG', 'mediagoblin.ini'))
if not os.path.exists(mgoblin_conf_file):
raise IOError(
"MEDIAGOBLIN_CONFIG not set or file does not exist")
- parser = NicerConfigParser(mgoblin_conf_file)
- parser.read(mgoblin_conf_file)
- parser._defaults.setdefault(
- 'here', os.path.dirname(os.path.abspath(mgoblin_conf_file)))
- parser._defaults.setdefault(
- '__file__', os.path.abspath(mgoblin_conf_file))
-
- mgoblin_section = dict(parser.items(mgoblin_section))
- mgoblin_conf = dict(
- [(section_name, dict(parser.items(section_name)))
- for section_name in parser.sections()])
+ # By setting the environment variable here we should ensure that
+ # this is the module that gets set up.
+ os.environ['CELERY_CONFIG_MODULE'] = OUR_MODULENAME
+ app.MediaGoblinApp(mgoblin_conf_file, setup_celery=False)
setup_celery_from_config(
- mgoblin_section, mgoblin_conf,
+ mg_globals.app_config, mg_globals.global_config,
settings_module=OUR_MODULENAME,
set_environ=False)
- connection, db = setup_connection_and_db_from_config(mgoblin_section)
-
- # Set up the storage systems.
- public_store = storage.storage_system_from_paste_config(
- mgoblin_section, 'publicstore')
- queue_store = storage.storage_system_from_paste_config(
- mgoblin_section, 'queuestore')
-
- workbench_manager = WorkbenchManager(
- mgoblin_section.get(
- 'workbench_path', DEFAULT_WORKBENCH_DIR))
-
- setup_globals(
- db_connection=connection,
- database=db,
- public_store=public_store,
- email_debug_mode=asbool(mgoblin_section.get('email_debug_mode')),
- email_sender_address=mgoblin_section.get(
- 'email_sender_address',
- 'notice@mediagoblin.example.org'),
- queue_store=queue_store,
- workbench_manager=workbench_manager)
-
if os.environ['CELERY_CONFIG_MODULE'] == OUR_MODULENAME:
setup_self()