mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
gnublade for patches and feedback.
This commit is contained in:
parent
1f8f4228f0
commit
df6855f310
@ -33,28 +33,11 @@ class DjangoApplication(Application):
|
|||||||
|
|
||||||
if not self.settings_modname:
|
if not self.settings_modname:
|
||||||
project_name = os.path.split(self.project_path)[-1]
|
project_name = os.path.split(self.project_path)[-1]
|
||||||
settings_name, ext = os.path.splitext(os.path.basename(settings_path))
|
settings_name, ext = os.path.splitext(
|
||||||
|
os.path.basename(settings_path))
|
||||||
self.settings_modname = "%s.%s" % (project_name, settings_name)
|
self.settings_modname = "%s.%s" % (project_name, settings_name)
|
||||||
os.environ[ENVIRONMENT_VARIABLE] = self.settings_modname
|
os.environ[ENVIRONMENT_VARIABLE] = self.settings_modname
|
||||||
else:
|
|
||||||
# try to check if we can import settings already.
|
|
||||||
try:
|
|
||||||
import settings
|
|
||||||
except ImportError:
|
|
||||||
# test if we are already in the project
|
|
||||||
# if not we try to use to find the module in current
|
|
||||||
# directory
|
|
||||||
project_path, settings_name = self.settings_modname.split(".")
|
|
||||||
aproject_path = os.path.abspath(os.path.join(os.getcwd(),
|
|
||||||
"..", project_path))
|
|
||||||
|
|
||||||
if aproject_path != self.project_path:
|
|
||||||
self.project_path = os.path.join(self.project_path,
|
|
||||||
project_path)
|
|
||||||
if not os.path.exists(self.project_path):
|
|
||||||
return self.no_settings(self.project_path,
|
|
||||||
import_error=True)
|
|
||||||
|
|
||||||
self.cfg.set("default_proc_name", self.settings_modname)
|
self.cfg.set("default_proc_name", self.settings_modname)
|
||||||
|
|
||||||
# add the project path to sys.path
|
# add the project path to sys.path
|
||||||
@ -67,8 +50,16 @@ class DjangoApplication(Application):
|
|||||||
def setup_environ(self):
|
def setup_environ(self):
|
||||||
from django.core.management import setup_environ
|
from django.core.management import setup_environ
|
||||||
try:
|
try:
|
||||||
import settings
|
parts = self.settings_modname.split(".")
|
||||||
setup_environ(settings)
|
settings_mod = __import__(self.settings_modname)
|
||||||
|
if len(parts) > 1:
|
||||||
|
settings_mod = __import__(parts[0])
|
||||||
|
path = os.path.dirname(os.path.abspath(
|
||||||
|
os.path.normpath(settings_mod.__file__)))
|
||||||
|
sys.path.append(path)
|
||||||
|
for part in parts[1:]:
|
||||||
|
settings_mod = getattr(settings_mod, part)
|
||||||
|
setup_environ(settings_mod)
|
||||||
except ImportError, e:
|
except ImportError, e:
|
||||||
return self.no_settings(self.settings_modname, import_error=True)
|
return self.no_settings(self.settings_modname, import_error=True)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user