try to use cwd() + gunicorn.conf.py as default config if no file is specified . see #52

This commit is contained in:
Jorge Niedbalski 2013-06-17 16:44:02 -03:00
parent e77d47cb97
commit 54b4ffb68e
2 changed files with 17 additions and 11 deletions

View File

@ -52,6 +52,15 @@ class Application(object):
for k, v in cfg.items():
self.cfg.set(k.lower(), v)
# Lastly, update the configuration with any command line
# settings.
for k, v in args.__dict__.items():
if v is None:
continue
if k == "args":
continue
self.cfg.set(k.lower(), v)
# Load up the config file if its found.
if args.config:
if not os.path.exists(args.config):
@ -81,14 +90,6 @@ class Application(object):
sys.stderr.write("Invalid value for %s: %s\n\n" % (k, v))
raise
# Lastly, update the configuration with any command line
# settings.
for k, v in args.__dict__.items():
if v is None:
continue
if k == "args":
continue
self.cfg.set(k.lower(), v)
def init(self, parser, opts, args):
raise NotImplementedError

View File

@ -199,7 +199,7 @@ class Setting(object):
"dest": self.name,
"action": self.action or "store",
"type": self.type or str,
"default": None,
"default": self.default or None,
"help": help_txt
}
@ -367,6 +367,12 @@ def validate_post_request(val):
else:
raise TypeError("Value must have an arity of: 4")
def get_default_config_file():
config_path = os.path.join(os.path.abspath(os.getcwd()), 'gunicorn.conf.py')
if os.path.exists(config_path):
return config_path
return None
class ConfigFile(Setting):
name = "config"
@ -374,7 +380,7 @@ class ConfigFile(Setting):
cli = ["-c", "--config"]
meta = "FILE"
validator = validate_string
default = None
default = get_default_config_file()
desc = """\
The path to a Gunicorn config file.
@ -382,7 +388,6 @@ class ConfigFile(Setting):
application specific configuration.
"""
class Bind(Setting):
name = "bind"
action = "append"