gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-bank] 02/02: Splitting settings for normal and admin


From: gnunet
Subject: [GNUnet-SVN] [taler-bank] 02/02: Splitting settings for normal and admin instances.
Date: Thu, 02 Feb 2017 15:12:56 +0100

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository bank.

commit 21c0afeeb14c2ed36dc6bd456eb3100d0f95a587
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Feb 2 15:11:54 2017 +0100

    Splitting settings for normal and admin instances.
---
 bank-admin.wsgi.in                          |   5 +-
 bank.wsgi.in                                |   3 -
 taler-bank-manage.in                        |   8 +-
 talerbank/settings.py                       | 185 +---------------------------
 talerbank/settings_admin.py                 |   2 +
 talerbank/{settings.py => settings_base.py} |   3 -
 6 files changed, 12 insertions(+), 194 deletions(-)

diff --git a/bank-admin.wsgi.in b/bank-admin.wsgi.in
index 93f035f..94dc5ed 100644
--- a/bank-admin.wsgi.in
+++ b/bank-admin.wsgi.in
@@ -6,16 +6,13 @@ if sys.version_info.major < 3:
     print("The taler bank needs to run with Python>=3.4")
     sys.exit(1)
 
-os.environ.setdefault("DJANGO_SETTINGS_MODULE", "talerbank.settings")
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "talerbank.settings_admin")
 os.environ.setdefault("TALER_PREFIX", "@prefix@")
 site.addsitedir("%s/lib/python%d.%d/site-packages" % (
     "@prefix@", 
     sys.version_info.major,
     sys.version_info.minor))
 
-from django.conf import settings
-settings.ROOT_URLCONF = 'talerbank.app.urlsadmin'
-
 import django
 django.setup()
 
diff --git a/bank.wsgi.in b/bank.wsgi.in
index ba1695a..f276b99 100644
--- a/bank.wsgi.in
+++ b/bank.wsgi.in
@@ -13,9 +13,6 @@ site.addsitedir("%s/lib/python%d.%d/site-packages" % (
     sys.version_info.major,
     sys.version_info.minor))
 
-from django.conf import settings
-settings.ROOT_URLCONF = 'talerbank.app.urls'
-
 import django
 django.setup()
 
diff --git a/taler-bank-manage.in b/taler-bank-manage.in
index 69b6e6f..911782f 100644
--- a/taler-bank-manage.in
+++ b/taler-bank-manage.in
@@ -10,7 +10,6 @@ import sys
 import os
 import site
 
-os.environ.setdefault("DJANGO_SETTINGS_MODULE", "talerbank.settings")
 os.environ.setdefault("TALER_PREFIX", "@prefix@")
 site.addsitedir("%s/lib/python%d.%d/site-packages" % (
     "@prefix@",
@@ -121,6 +120,13 @@ p.set_defaults(func=handle_config)
 args = parser.parse_args()
 
 token = "bank%s" % ("-admin" if args.admin else "")
+
+settings_module = "talerbank.settings"
+if token == "bank-admin":
+    settings_module = "talerbank.settings_admin"
+
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", settings_module)
+
 logger.info("Setting token to %s" % token)
 
 if args.altdb:
diff --git a/talerbank/settings.py b/talerbank/settings.py
index 4625fe7..6542acf 100644
--- a/talerbank/settings.py
+++ b/talerbank/settings.py
@@ -1,183 +1,2 @@
-"""
-Django settings for talerbank.
-
-For more information on this file, see
-https://docs.djangoproject.com/en/1.9/topics/settings/
-
-For the full list of settings and their values, see
-https://docs.djangoproject.com/en/1.9/ref/settings/
-"""
-
-import os
-import logging
-import base64
-from .talerconfig import TalerConfig
-import sys
-import urllib.parse
-
-logger = logging.getLogger(__name__)
-
-tc = TalerConfig.from_file(os.environ.get("TALER_CONFIG_FILE"))
-
-# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
-BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
-
-# Quick-start development settings - unsuitable for production
-# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
-
-
-SECRET_KEY = os.environ.get("TALER_BANK_SECRET_KEY", None)
-
-if not SECRET_KEY:
-    logging.info("secret key not configured in TALER_BANK_SECRET_KEY env 
variable, generating random secret")
-    SECRET_KEY = base64.b64encode(os.urandom(32)).decode('utf-8')
-
-# SECURITY WARNING: don't run with debug turned on in production!
-DEBUG = True
-
-ALLOWED_HOSTS = ["*"]
-
-LOGIN_URL = "login"
-
-LOGIN_REDIRECT_URL = "index"
-
-
-# Application definition
-
-INSTALLED_APPS = [
-    'django.contrib.admin',
-    'django.contrib.auth',
-    'django.contrib.contenttypes',
-    'django.contrib.sessions',
-    'django.contrib.messages',
-    'django.contrib.staticfiles',
-    'talerbank.app'
-]
-
-MIDDLEWARE_CLASSES = [
-    'django.middleware.security.SecurityMiddleware',
-    'django.contrib.sessions.middleware.SessionMiddleware',
-    'django.middleware.common.CommonMiddleware',
-    'django.middleware.csrf.CsrfViewMiddleware',
-    'django.contrib.auth.middleware.AuthenticationMiddleware',
-    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
-    'django.contrib.messages.middleware.MessageMiddleware',
-    'django.middleware.clickjacking.XFrameOptionsMiddleware',
-]
-
-# To be dynamically set at launch time (by *.wsgi scripts)
-ROOT_URLCONF = ''
-
-TEMPLATES = [
-    {
-        'BACKEND': 'django.template.backends.django.DjangoTemplates',
-        'DIRS': [os.path.join(BASE_DIR, "talerbank/app/static/web-common/")],
-        'APP_DIRS': True,
-        'OPTIONS': {
-            'context_processors': [
-                'django.template.context_processors.debug',
-                'django.template.context_processors.request',
-                'django.contrib.auth.context_processors.auth',
-                'django.contrib.messages.context_processors.messages',
-            ],
-        },
-    },
-]
-
-WSGI_APPLICATION = 'talerbank.wsgi.application'
-
-
-# Database
-# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
-
-DATABASES = {}
-
-# parse a database URL, django can't natively do this!
-dbname = tc.value_string("bank", "database", required=False)
-dbconfig = {}
-if dbname:
-    db_url = urllib.parse.urlparse(dbname)
-    if db_url.scheme != "postgres":
-        raise Exception("only postgres db is supported ('{}' not 
understood)".format(dbname))
-    dbconfig['ENGINE'] = 'django.db.backends.postgresql_psycopg2'
-    dbconfig['NAME'] = db_url.path.lstrip("/")
-
-    if not db_url.netloc:
-        p = urllib.parse.parse_qs(db_url.query)
-        if ("host" not in p) or len(p["host"]) == 0:
-            host = None
-        else:
-            host = p["host"][0]
-    else:
-        host = db_url.netloc
-
-    if host:
-        dbconfig["HOST"] = host
-
-    logger.info("db string '%s'", dbname)
-    logger.info("db info '%s'", dbconfig)
-
-    DATABASES["default"] = dbconfig
-else:
-    DATABASES["default"] = {
-            'ENGINE': 'django.db.backends.sqlite3',
-            'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
-    }
-
-
-# Password validation
-# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
-
-AUTH_PASSWORD_VALIDATORS = [
-    {
-        'NAME': 
'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
-    },
-    {
-        'NAME': 
'django.contrib.auth.password_validation.MinimumLengthValidator',
-    },
-    {
-        'NAME': 
'django.contrib.auth.password_validation.CommonPasswordValidator',
-    },
-    {
-        'NAME': 
'django.contrib.auth.password_validation.NumericPasswordValidator',
-    },
-]
-
-
-# Internationalization
-# https://docs.djangoproject.com/en/1.9/topics/i18n/
-
-LANGUAGE_CODE = 'en-us'
-
-TIME_ZONE = 'UTC'
-
-USE_I18N = True
-
-USE_L10N = True
-
-USE_TZ = True
-
-
-# Static files (CSS, JavaScript, Images)
-# https://docs.djangoproject.com/en/1.9/howto/static-files/
-
-STATIC_URL = '/static/'
-
-STATICFILES_DIRS = [
-    os.path.join(BASE_DIR, "talerbank/app/static"),
-]
-
-# Currently we don't use "collectstatic", so this value isn't used.
-# Instead, we serve static files directly from the installed python package
-# via the "django.contrib.staticfiles" app.
-# We must set it to something valid though, # or django will give us warnings.
-STATIC_ROOT = '/tmp/talerbankstatic/'
-
-
-
-TALER_CURRENCY = tc.value_string("taler", "currency", required=True)
-TALER_DIGITS = 2
-TALER_PREDEFINED_ACCOUNTS = ['Tor', 'GNUnet', 'Taler', 'FSF', 'Tutorial']
-TALER_EXPECTS_DONATIONS = ['Tor', 'GNUnet', 'Taler', 'FSF']
-
-logging.info("currency: '%s'", TALER_CURRENCY)
+from talerbank.settings_base import *
+ROOT_URLCONF = "talerbank.app.urls"
diff --git a/talerbank/settings_admin.py b/talerbank/settings_admin.py
new file mode 100644
index 0000000..b2ce6a3
--- /dev/null
+++ b/talerbank/settings_admin.py
@@ -0,0 +1,2 @@
+from talerbank.settings_base import *
+ROOT_URLCONF = "talerbank.app.urlsadmin"
diff --git a/talerbank/settings.py b/talerbank/settings_base.py
similarity index 98%
copy from talerbank/settings.py
copy to talerbank/settings_base.py
index 4625fe7..b97b021 100644
--- a/talerbank/settings.py
+++ b/talerbank/settings_base.py
@@ -65,9 +65,6 @@ MIDDLEWARE_CLASSES = [
     'django.middleware.clickjacking.XFrameOptionsMiddleware',
 ]
 
-# To be dynamically set at launch time (by *.wsgi scripts)
-ROOT_URLCONF = ''
-
 TEMPLATES = [
     {
         'BACKEND': 'django.template.backends.django.DjangoTemplates',

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]