diff --git a/gunicorn/app/djangoapp.py b/gunicorn/app/djangoapp.py index 11d5aab3..7cdfde06 100644 --- a/gunicorn/app/djangoapp.py +++ b/gunicorn/app/djangoapp.py @@ -10,6 +10,7 @@ from django.core.handlers.wsgi import WSGIHandler from django.core.servers.basehttp import AdminMediaHandler, WSGIServerException from gunicorn import util +from gunicorn.config import Config from gunicorn.app.base import Application class DjangoApplication(Application): @@ -30,8 +31,8 @@ class DjangoApplication(Application): project_name = os.path.split(self.project_path)[-1] settings_name, ext = os.path.splitext(os.path.basename(settings_path)) - settings_modname = "%s.%s" % (project_name, settings_name) - self.cfg.default_proc_name = settings_modname + self.settings_modname = "%s.%s" % (project_name, settings_name) + self.cfg.set("default_proc_name", self.settings_modname) sys.path.insert(0, self.project_path) sys.path.append(os.path.join(self.project_path, os.pardir)) @@ -48,8 +49,12 @@ class DjangoApplication(Application): class DjangoApplicationCommand(Application): - def __init__(self, cfg, admin_media_path): - self.cfg = cfg + def __init__(self, options, admin_media_path): + self.cfg = Config() + for k, v in list(options.items()): + if k.lower() in self.cfg.settings and v is not None: + self.cfg.set(k.lower(), v) + self.admin_media_path = admin_media_path self.configure_logging() diff --git a/gunicorn/config.py b/gunicorn/config.py index 30566421..bcde9e31 100644 --- a/gunicorn/config.py +++ b/gunicorn/config.py @@ -20,7 +20,7 @@ KNOWN_SETTINGS = [] class Config(object): - def __init__(self, usage): + def __init__(self, usage=None): self.settings = dict((s.name, s) for s in KNOWN_SETTINGS) self.usage = usage diff --git a/gunicorn/management/commands/run_gunicorn.py b/gunicorn/management/commands/run_gunicorn.py index 204b3e15..e1b342f4 100644 --- a/gunicorn/management/commands/run_gunicorn.py +++ b/gunicorn/management/commands/run_gunicorn.py @@ -53,18 +53,17 @@ class Command(BaseCommand): options['bind'] = addrport or '127.0.0.1' options['default_proc_name'] =settings.SETTINGS_MODULE - cfg = Config(options, options.get('gconfig')) - admin_media_path = options.get('admin_media_path', '') + admin_media_path = options.pop('admin_media_path', '') quit_command = (sys.platform == 'win32') and 'CTRL-BREAK' or 'CONTROL-C' print "Validating models..." self.validate(display_num_errors=True) print "\nDjango version %s, using settings %r" % (django.get_version(), settings.SETTINGS_MODULE) - print "Development server is running at %s" % str(cfg.address) + print "Development server is running at %s" % options['bind'] print "Quit the server with %s." % quit_command # django.core.management.base forces the locale to en-us. translation.activate(settings.LANGUAGE_CODE) - DjangoApplicationCommand(cfg, admin_media_path).run() + DjangoApplicationCommand(options, admin_media_path).run()