From: Christopher Allan Webber Date: Thu, 14 Jul 2011 04:14:42 +0000 (-0500) Subject: Merge branch 'master' into f411_new_migrations X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=c47c37ed953689e70441c4c143e4c06f1645be7d;p=mediagoblin.git Merge branch 'master' into f411_new_migrations Conflicts: mediagoblin/db/open.py --- c47c37ed953689e70441c4c143e4c06f1645be7d diff --cc mediagoblin/app.py index 523b9302,147db09c..7a6a1f33 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@@ -20,19 -20,12 +20,13 @@@ import urlli import routes from webob import Request, exc - from mediagoblin import routing, util, storage, staticdirect - from mediagoblin.init.config import ( - read_mediagoblin_config, generate_validation_report) + from mediagoblin import routing, util, storage from mediagoblin.db.open import setup_connection_and_db_from_config +from mediagoblin.db.util import MigrationManager from mediagoblin.mg_globals import setup_globals from mediagoblin.init.celery import setup_celery_from_config - from mediagoblin.init import get_jinja_loader - from mediagoblin.workbench import WorkbenchManager - - - class Error(Exception): pass - class ImproperlyConfigured(Error): pass + from mediagoblin.init import get_jinja_loader, get_staticdirector, \ + setup_global_and_app_config, setup_workbench class MediaGoblinApp(object): diff --cc mediagoblin/db/open.py index cb040c29,b6987677..e5fde6f9 --- a/mediagoblin/db/open.py +++ b/mediagoblin/db/open.py @@@ -29,26 -24,14 +29,27 @@@ def connect_database_from_config(app_co port = app_config.get('db_port') if port: port = asint(port) - connection = mongokit.Connection( - app_config.get('db_host'), port) + + if use_pymongo: + connection = pymongo.Connection( + app_config.get('db_host'), port) + else: + connection = mongokit.Connection( + app_config.get('db_host'), port) return connection -def setup_connection_and_db_from_config(app_config): - connection = connect_database_from_config(app_config) ++ +def setup_connection_and_db_from_config(app_config, use_pymongo=False): + """ + Setup connection and database from config. + + Optionally use pymongo instead of mongokit. + """ + connection = connect_database_from_config(app_config, use_pymongo) - database_path = app_config.get('db_name', 'mediagoblin') + database_path = app_config['db_name'] db = connection[database_path] - models.register_models(connection) - # Could configure indexes here on db + + if not use_pymongo: + models.register_models(connection) + return (connection, db)