gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-bank] branch master updated (471ebf4 -> 21c0afe)


From: gnunet
Subject: [GNUnet-SVN] [taler-bank] branch master updated (471ebf4 -> 21c0afe)
Date: Thu, 02 Feb 2017 15:12:54 +0100

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

marcello pushed a change to branch master
in repository bank.

    from 471ebf4  /add/admin testcase fixed but ROOT_URLCONF doesn't switch 
between normal and admin url-views mapping.
     new 678bc32  Explicitly importing urlconf from reverse()
     new 21c0afe  Splitting settings for normal and admin instances.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 bank-admin.wsgi.in                          |   5 +-
 bank.wsgi.in                                |   3 -
 taler-bank-manage.in                        |   8 +-
 talerbank/app/tests.py                      |  12 +-
 talerbank/settings.py                       | 185 +---------------------------
 talerbank/settings_admin.py                 |   2 +
 talerbank/{settings.py => settings_base.py} |   3 -
 7 files changed, 16 insertions(+), 202 deletions(-)
 create mode 100644 talerbank/settings_admin.py
 copy talerbank/{settings.py => settings_base.py} (98%)

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/app/tests.py b/talerbank/app/tests.py
index 9981b04..a5af7c9 100644
--- a/talerbank/app/tests.py
+++ b/talerbank/app/tests.py
@@ -19,6 +19,7 @@ from django.core.urlresolvers import reverse
 from django.conf import settings
 from django.contrib.auth.models import User
 from .models import BankAccount
+from . import urlsadmin, urls
 
 import logging
 
@@ -37,15 +38,13 @@ class RegisterTestCase(TestCase):
         ba = BankAccount(user=bank, currency=settings.TALER_CURRENCY)
         ba.account_no = 1
         ba.save() 
-        settings.configure(ROOT_URLCONF="talerbank.app.urls")
 
     def tearDown(self):
         clearDb()
 
     def test_register(self):
         c = Client()
-        logger.info("My ROOT_URLCONF, {}".format(settings.ROOT_URLCONF))
-        response = c.post(reverse("register"),
+        response = c.post(reverse("register", urlconf=urls),
                           {"username": "test_register",
                            "password": "test_register"},
                            follow=True)
@@ -63,7 +62,6 @@ class LoginTestCase(TestCase):
         user_account = BankAccount(user=user,
                                    currency=settings.TALER_CURRENCY)
         user_account.save()
-        settings.configure(ROOT_URLCONF="talerbank.app.urls")
 
 
     def tearDown(self):
@@ -72,8 +70,7 @@ class LoginTestCase(TestCase):
 
     def test_login(self):
         c = Client()
-        logger.info("My ROOT_URLCONF, {}".format(settings.ROOT_URLCONF))
-        response = c.post(reverse("login"),
+        response = c.post(reverse("login", urlconf=urls),
                           {"username": "test_user",
                            "password": "test_password"},
                            follow=True)
@@ -93,7 +90,6 @@ class AddIncomingTestCase(TestCase):
                                    currency=settings.TALER_CURRENCY)
         bank_account.save()
         user_account.save()
-        settings.configure(ROOT_URLCONF="talerbank.app.urlsadmin")
 
     def tearDown(self):
         clearDb()
@@ -101,7 +97,7 @@ class AddIncomingTestCase(TestCase):
     def test_add_incoming(self):
         c = Client()
         data = '{"debit_account":1, "credit_account":2, "wtid":"TESTWTID", 
"amount":{"value":1, "fraction":0, "currency":"%s"}}' % settings.TALER_CURRENCY
-        response = c.post(reverse("add-incoming"),
+        response = c.post(reverse("add-incoming", urlconf=urlsadmin),
                           data=data,
                           content_type="application/json",
                           follow=True)
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]