summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/settings.py
diff options
context:
space:
mode:
authorTim Laszlo <tim.laszlo@gmail.com>2012-08-07 13:37:33 -0500
committerTim Laszlo <tim.laszlo@gmail.com>2012-08-07 13:37:33 -0500
commit5b3ffd488a8b5f727a531a3b7c3ca419bb53d04e (patch)
treee816129405d12aad7069b7450b9121ed201ea23b /src/lib/Bcfg2/settings.py
parentcb928a1f548fe1e65933ecbb62220295802f160b (diff)
downloadbcfg2-5b3ffd488a8b5f727a531a3b7c3ca419bb53d04e.tar.gz
bcfg2-5b3ffd488a8b5f727a531a3b7c3ca419bb53d04e.tar.bz2
bcfg2-5b3ffd488a8b5f727a531a3b7c3ca419bb53d04e.zip
Merge reporting configuration with main server configuration
Admin/Syncdb: Use SchemaUpdater Move the schema update routines from reports to Bcfg2.Server Move Reports.settings into Bcfg2.settings
Diffstat (limited to 'src/lib/Bcfg2/settings.py')
-rw-r--r--src/lib/Bcfg2/settings.py111
1 files changed, 101 insertions, 10 deletions
diff --git a/src/lib/Bcfg2/settings.py b/src/lib/Bcfg2/settings.py
index c72ef0ebe..815a9529b 100644
--- a/src/lib/Bcfg2/settings.py
+++ b/src/lib/Bcfg2/settings.py
@@ -1,3 +1,6 @@
+# TODO
+# since were merging configs load and warn on deprecated fields
+
import sys
import Bcfg2.Options
@@ -17,9 +20,18 @@ DATABASE_PASSWORD = None
DATABASE_HOST = None
DATABASE_PORT = None
+TIME_ZONE = None
+
+DEBUG = False
+TEMPLATE_DEBUG = DEBUG
+
+MEDIA_URL = '/site_media'
+
+
def read_config(cfile='/etc/bcfg2.conf', repo=None, quiet=False):
global DATABASE_ENGINE, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD, \
- DATABASE_HOST, DATABASE_PORT
+ DATABASE_HOST, DATABASE_PORT, DEBUG, TEMPLATE_DEBUG, TIME_ZONE, \
+ MEDIA_URL
setup = \
Bcfg2.Options.OptionParser(dict(repo=Bcfg2.Options.SERVER_REPOSITORY,
@@ -29,9 +41,12 @@ def read_config(cfile='/etc/bcfg2.conf', repo=None, quiet=False):
db_user=Bcfg2.Options.DB_USER,
db_password=Bcfg2.Options.DB_PASSWORD,
db_host=Bcfg2.Options.DB_HOST,
- db_port=Bcfg2.Options.DB_PORT),
+ db_port=Bcfg2.Options.DB_PORT,
+ time_zone=Bcfg2.Options.DJANGO_TIME_ZONE,
+ django_debug=Bcfg2.Options.DJANGO_DEBUG,
+ web_prefix=Bcfg2.Options.DJANGO_WEB_PREFIX),
quiet=quiet)
- setup.parse([Bcfg2.Options.CFILE.cmd, cfile])
+ setup.parse([Bcfg2.Options.CFILE.cmd, '/etc/bcfg2-web.conf', cfile])
if repo is None:
repo = setup['repo']
@@ -52,16 +67,25 @@ def read_config(cfile='/etc/bcfg2.conf', repo=None, quiet=False):
DATABASE_HOST = DATABASES['default']['HOST']
DATABASE_PORT = DATABASES['default']['PORT']
+ # dropping the version check. This was added in 1.1.2
+ TIME_ZONE = setup['time_zone']
+
+ DEBUG = setup['django_debug']
+ TEMPLATE_DEBUG = DEBUG
+ if DEBUG:
+ print("Warning: Setting web_debug to True causes extraordinary memory "
+ "leaks. Only use this setting if you know what you're doing.")
+
+ if setup['web_prefix']:
+ MEDIA_URL = setup['web_prefix'].rstrip('/') + MEDIA_URL
+ else:
+ MEDIA_URL = '/site_media'
+
+
# initialize settings from /etc/bcfg2.conf, or set up basic defaults.
# this lets manage.py work in all cases
read_config(quiet=True)
-if has_django and django.VERSION[0] == 1 and django.VERSION[1] > 2:
- TIME_ZONE = None
-
-DEBUG = False
-TEMPLATE_DEBUG = DEBUG
-
ADMINS = (('Root', 'root'))
MANAGERS = ADMINS
@@ -72,5 +96,72 @@ LANGUAGE_CODE = 'en-us'
SITE_ID = 1
-INSTALLED_APPS = ('Bcfg2.Server')
+# TODO - sanitize this
+INSTALLED_APPS = (
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.sites',
+ 'django.contrib.admin',
+ 'Bcfg2.Server.Reports.reports',
+ 'Bcfg2.Server'
+)
+
+# Imported from Bcfg2.Server.Reports
+MEDIA_ROOT = ''
+
+# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
+# trailing slash.
+ADMIN_MEDIA_PREFIX = '/media/'
+
+#TODO - make this unique
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = 'eb5+y%oy-qx*2+62vv=gtnnxg1yig_odu0se5$h0hh#pc*lmo7'
+
+TEMPLATE_LOADERS = (
+ 'django.template.loaders.filesystem.load_template_source',
+ 'django.template.loaders.app_directories.load_template_source',
+)
+
+#TODO - review these. auth and sessions aren't really used
+MIDDLEWARE_CLASSES = (
+ 'django.middleware.common.CommonMiddleware',
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'django.middleware.doc.XViewMiddleware',
+)
+
+# TODO - move this to a higher root and dynamically import
+ROOT_URLCONF = 'Bcfg2.Server.Reports.urls'
+
+# TODO - this isn't usable
+# Authentication Settings
+AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend')
+
+LOGIN_URL = '/login'
+
+SESSION_EXPIRE_AT_BROWSER_CLOSE = True
+
+TEMPLATE_DIRS = (
+ # App loaders should take care of this.. not sure why this is here
+ '/usr/share/python-support/python-django/django/contrib/admin/templates/',
+)
+
+# TODO - sanitize this
+if django.VERSION[0] == 1 and django.VERSION[1] < 2:
+ TEMPLATE_CONTEXT_PROCESSORS = (
+ 'django.core.context_processors.auth',
+ 'django.core.context_processors.debug',
+ 'django.core.context_processors.i18n',
+ 'django.core.context_processors.media',
+ 'django.core.context_processors.request'
+ )
+else:
+ TEMPLATE_CONTEXT_PROCESSORS = (
+ 'django.contrib.auth.context_processors.auth',
+ 'django.core.context_processors.debug',
+ 'django.core.context_processors.i18n',
+ 'django.core.context_processors.media',
+ 'django.core.context_processors.request'
+ )