From fad7353d51f249b3f3879bcc5891ebc31f9ad25a Mon Sep 17 00:00:00 2001 From: benoitc Date: Sun, 26 Aug 2012 21:46:20 +0200 Subject: [PATCH] allows gunicorn to load a pre-compiled app. close #316 Patch adapted from the one submitted from @rbdrbd with a small change to reuse the code. --- gunicorn/app/djangoapp.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gunicorn/app/djangoapp.py b/gunicorn/app/djangoapp.py index 6e566fea..0d20da4e 100644 --- a/gunicorn/app/djangoapp.py +++ b/gunicorn/app/djangoapp.py @@ -9,6 +9,11 @@ import sys from gunicorn.app.base import Application from gunicorn import util +def is_setting_mod(path): + return (os.path.isfile(os.path.join(path, "settings.py")) or + os.path.isfile(os.path.join(path, "settings.pyc"))) + + def find_settings_module(path): path = os.path.abspath(path) project_path = None @@ -16,13 +21,13 @@ def find_settings_module(path): if os.path.isdir(path): project_path = None - if not os.path.isfile(os.path.join(path, "settings.py")): + if not is_setting_mod(path): for d in os.listdir(path): if d in ('..', '.'): continue root = os.path.join(path, d) - if os.path.isfile(os.path.join(root, "settings.py")): + if is_setting_mod(root): project_path = root break else: