Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

allow multiple sites, with manage.py coping with different settings l…

…ocations
  • Loading branch information...
commit 9dddf1dde7d222f85aec4528bf706b7a15fa3bda 1 parent d905e3c
@andymckay andymckay authored
View
1  .gitignore
@@ -1,4 +1,5 @@
settings_local.py*
+settings_local_*.py
*.py[co]
*.sw[po]
.coverage
View
0  default/__init__.py
No changes.
View
1  default/settings.py
@@ -0,0 +1 @@
+ROOT_URLCONF = 'default.urls'
View
1  default/urls.py
@@ -0,0 +1 @@
+from lib.urls_base import *
View
0  log_settings.py → lib/log_settings_base.py
File renamed without changes
View
11 settings.py → lib/settings_base.py
@@ -21,8 +21,8 @@
# jingo-minify: Style sheet media attribute default
CSS_MEDIA_DEFAULT = 'all'
-# Make filepaths relative to settings.
-ROOT = os.path.dirname(os.path.abspath(__file__))
+# Make filepaths relative to the root of zamboni.
+ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
path = lambda *a: os.path.join(ROOT, *a)
# We need to track this because hudson can't just call its checkout "zamboni".
@@ -334,7 +334,8 @@ def JINJA_CONFIG():
)
AUTH_PROFILE_MODULE = 'users.UserProfile'
-ROOT_URLCONF = '%s.urls' % ROOT_PACKAGE
+# Override this in the site settings.
+ROOT_URLCONF = 'lib.urls_base'
INSTALLED_APPS = (
'amo', # amo comes first so it always takes precedence.
@@ -373,10 +374,6 @@ def JINJA_CONFIG():
'versions',
'webapps',
'zadmin',
-
- # We need this so the jsi18n view will pick up our locale directory.
- ROOT_PACKAGE,
-
'cake',
# Third party apps
View
0  urls.py → lib/urls_base.py
File renamed without changes
View
48 manage.py
@@ -1,10 +1,10 @@
#!/usr/bin/env python
+import getopt
import logging
import os
import site
import sys
-import warnings
-
+import imp
ROOT = os.path.dirname(os.path.abspath(__file__))
if os.path.splitext(os.path.basename(__file__))[0] == 'cProfile':
@@ -34,21 +34,34 @@
from django.core.management import (call_command, execute_manager,
setup_environ)
+# Figuring out what settings file to use.
+# 1. Look first for the command line setting.
+setting = None
+found, rest = getopt.getopt(sys.argv[1:], 's:', 'settings=')
@cvan Owner
cvan added a note

if we want the name of the settings file shouldn't this be sys.argv[2:]? http://dpaste.com/hold/702965/

@andymckay Owner

Sure, we moved the location of --settings around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
try:
- import settings_local as settings
-except ImportError:
- try:
- import settings
- except ImportError:
- import sys
- sys.stderr.write(
- "Error: Tried importing 'settings_local.py' and 'settings.py' "
- "but neither could be found (or they're throwing an ImportError)."
- " Please come back and try again later.")
- raise
-
-if not settings.DEBUG:
- warnings.simplefilter('ignore')
+ setting = dict(found).values()[0]
+except IndexError:
+ pass
+
+# 2. If not, find the env variable.
+if not setting:
+ setting = os.environ.get('DJANGO_SETTINGS_MODULE', '')
+
+# The average Django user will have DJANGO_SETTINGS_MODULE set to settings
+# for our purposes that means, load the default site, so if nothing is
+# specified by now, use the default.
+if setting in ('settings', ''):
+ setting = 'settings_local'
+
+# Django runserver does that double reload of installed settings, settings
+# setting to zamboni.settings. We don't want to have zamboni on the path.
+if setting.startswith('zamboni'):
+ setting = setting[len('zamboni.'):]
+
+# Finally load the settings file that was specified.
+res = imp.find_module(setting)
+settings = imp.load_module(setting, *res)
+os.environ['DJANGO_SETTINGS_MODULE'] = setting
# The first thing execute_manager does is call `setup_environ`. Logging config
# needs to access settings, so we'll setup the environ early.
@@ -79,7 +92,7 @@ def new(self, arg):
# Import for side-effect: configures our logging handlers.
# pylint: disable-msg=W0611
-import log_settings
+from lib import log_settings_base
import djcelery
djcelery.setup_loader()
@@ -97,3 +110,4 @@ def new(self, arg):
product_details.__init__() # reload the product details
execute_manager(settings)
+
View
0  mkt/__init__.py
No changes.
View
5 mkt/settings.py
@@ -0,0 +1,5 @@
+from lib.settings_base import *
+
+APP_PREVIEW = True
+ROOT_URLCONF = 'mkt.urls'
+TEMPLATE_DIRS = (path('mkt/templates'),) + TEMPLATE_DIRS
View
1  mkt/urls.py
@@ -0,0 +1 @@
+from lib.urls_base import *
Please sign in to comment.
Something went wrong with that request. Please try again.