From 1faea032636b854799dd30e9cda5ca6d2ae76fbd Mon Sep 17 00:00:00 2001 From: benoitc Date: Wed, 16 May 2012 08:45:35 +0200 Subject: [PATCH] found the settings file in eahc nested folders. Fix issue #340 --- gunicorn/app/djangoapp.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/gunicorn/app/djangoapp.py b/gunicorn/app/djangoapp.py index 4b4c8790..6e566fea 100644 --- a/gunicorn/app/djangoapp.py +++ b/gunicorn/app/djangoapp.py @@ -16,15 +16,17 @@ def find_settings_module(path): if os.path.isdir(path): project_path = None - lvl = 0 - for root, dirs, files in os.walk(path): - if "settings.py" in files: - project_path = root - break + if not os.path.isfile(os.path.join(path, "settings.py")): + for d in os.listdir(path): + if d in ('..', '.'): + continue - lvl += 1 - if lvl > 2: - break + root = os.path.join(path, d) + if os.path.isfile(os.path.join(root, "settings.py")): + project_path = root + break + else: + project_path = path elif os.path.isfile(path): project_path = os.path.dirname(path) settings_name, _ = os.path.splitext(os.path.basename(path))