From a1eb1f6051300e5d3ce9d1f32d28a25a567e73d8 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Sun, 8 May 2011 07:16:50 -0500 Subject: [PATCH] Only convert db port if it's there and use asint to do it (better errors if failing) --- mediagoblin/app.py | 6 ++++-- mediagoblin/celery_setup/from_celery.py | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/mediagoblin/app.py b/mediagoblin/app.py index 5c094f38..913e530e 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -18,7 +18,7 @@ import urllib import routes import mongokit -from paste.deploy.converters import asbool +from paste.deploy.converters import asint from webob import Request, exc from mediagoblin import routing, util, models, storage, staticdirect @@ -114,7 +114,9 @@ class MediaGoblinApp(object): def paste_app_factory(global_config, **app_config): # Get the database connection - port = int(app_config.get('db_port')) + port = app_config.get('db_port') + if port: + port = asint(port) connection = mongokit.Connection( app_config.get('db_host'), port) diff --git a/mediagoblin/celery_setup/from_celery.py b/mediagoblin/celery_setup/from_celery.py index 0ddfcc76..6561c622 100644 --- a/mediagoblin/celery_setup/from_celery.py +++ b/mediagoblin/celery_setup/from_celery.py @@ -18,6 +18,7 @@ import os import mongokit from paste.deploy.loadwsgi import NicerConfigParser +from paste.deploy.converters import asint from mediagoblin import storage, models from mediagoblin.celery_setup import setup_celery_from_config @@ -67,8 +68,11 @@ def setup_self(setup_globals_func=setup_globals): settings_module=OUR_MODULENAME, set_environ=False) + port = mgoblin_section.get('db_port') + if port: + port = asint(port) connection = mongokit.Connection( - mgoblin_section.get('db_host'), mgoblin_section.get('db_port')) + mgoblin_section.get('db_host'), port) db = connection[mgoblin_section.get('db_name', 'mediagoblin')] models.register_models(connection) -- 2.25.1