expose --pythonpath command to all modes . fix #433

--pythonpath may also be useful in other commands, so expose it to all.
This commit is contained in:
benoitc 2012-11-07 09:52:49 +01:00
parent 23f66c2389
commit 9fb0d9669c
4 changed files with 18 additions and 5 deletions

View File

@ -482,6 +482,9 @@ The Python path to a Django settings module.
e.g. 'myproject.settings.main'. If this isn't provided, the
DJANGO_SETTINGS_MODULE environment variable will be used.
Server Mechanics
----------------
pythonpath
~~~~~~~~~~

View File

@ -115,6 +115,14 @@ class Application(object):
if self.cfg.daemon:
util.daemonize()
# set python paths
if self.cfg.pythonpath and self.cfg.pythonpath is not None:
paths = self.cfg.pythonpath.split(",")
for path in paths:
pythonpath = os.path.abspath(self.cfg.pythonpath)
if pythonpath not in sys.path:
sys.path.insert(0, pythonpath)
try:
Arbiter(self).run()
except RuntimeError as e:

View File

@ -44,9 +44,11 @@ def make_default_env(cfg):
os.environ['DJANGO_SETTINGS_MODULE'] = cfg.django_settings
if cfg.pythonpath and cfg.pythonpath is not None:
pythonpath = os.path.abspath(cfg.pythonpath)
if pythonpath not in sys.path:
sys.path.insert(0, pythonpath)
paths = cfg.pythonpath.split(",")
for path in paths:
pythonpath = os.path.abspath(cfg.pythonpath)
if pythonpath not in sys.path:
sys.path.insert(0, pythonpath)
try:
os.environ['DJANGO_SETTINGS_MODULE']

View File

@ -867,9 +867,9 @@ class DjangoSettings(Setting):
DJANGO_SETTINGS_MODULE environment variable will be used.
"""
class DjangoPythonPath(Setting):
class PythonPath(Setting):
name = "pythonpath"
section = "Django"
section = "Server Mechanics"
cli = ["--pythonpath"]
meta = "STRING"
validator = validate_string