From 5094990c9ab97c6cc86f1708c340b7ad26e18588 Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Sun, 31 Jan 2016 16:32:14 +0100 Subject: [PATCH] Switch from deprecated amqp backend to rpc The previously used amqp result backend has been marked as deprecated by the celery developers. This commit switches to the rpc backend that should be used instead. This commit renames get_env_setting to get_env_variable to be consistent with the gva settings modules. --- gvaldap/gvaldap/settings/base.py | 36 +++++++++++++------------- gvaldap/gvaldap/settings/production.py | 4 +-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/gvaldap/gvaldap/settings/base.py b/gvaldap/gvaldap/settings/base.py index 3d12927..02fec0f 100644 --- a/gvaldap/gvaldap/settings/base.py +++ b/gvaldap/gvaldap/settings/base.py @@ -5,28 +5,28 @@ Common settings and globals. """ +from os import environ from os.path import abspath, basename, dirname, join, normpath from sys import path -from os import environ # Normally you should not import ANYTHING from Django directly # into your settings, but ImproperlyConfigured is an exception. from django.core.exceptions import ImproperlyConfigured -def get_env_setting(setting): +def get_env_variable(var_name): """ - Get the environment setting or return exception. + Get a setting from an environment variable. - :param str setting: name of an environment setting + :param str var_name: variable name :raises ImproperlyConfigured: if the environment setting is not defined :return: environment setting value :rtype: str """ try: - return environ[setting] + return environ[var_name] except KeyError: - error_msg = "Set the %s env variable" % setting + error_msg = "Set the %s environment variable" % var_name raise ImproperlyConfigured(error_msg) @@ -58,7 +58,7 @@ TEMPLATE_DEBUG = DEBUG ########## MANAGER CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#admins ADMINS = ( - (get_env_setting('GVALDAP_ADMIN_NAME'), get_env_setting('GVALDAP_ADMIN_EMAIL')), + (get_env_variable('GVALDAP_ADMIN_NAME'), get_env_variable('GVALDAP_ADMIN_EMAIL')), ) # See: https://docs.djangoproject.com/en/dev/ref/settings/#managers @@ -79,9 +79,9 @@ DATABASES = { }, 'ldap': { 'ENGINE': 'ldapdb.backends.ldap', - 'NAME': get_env_setting('GVALDAP_LDAP_URL'), - 'USER': get_env_setting('GVALDAP_LDAP_USER'), - 'PASSWORD': get_env_setting('GVALDAP_LDAP_PASSWORD'), + 'NAME': get_env_variable('GVALDAP_LDAP_URL'), + 'USER': get_env_variable('GVALDAP_LDAP_USER'), + 'PASSWORD': get_env_variable('GVALDAP_LDAP_PASSWORD'), } } DATABASE_ROUTERS = ['ldapdb.router.Router'] @@ -141,7 +141,7 @@ STATICFILES_FINDERS = ( ########## SECRET CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key # Note: This key should only be used for development and testing. -SECRET_KEY = get_env_setting('GVALDAP_SECRETKEY') +SECRET_KEY = get_env_variable('GVALDAP_SECRETKEY') ########## END SECRET CONFIGURATION @@ -279,15 +279,15 @@ WSGI_APPLICATION = '%s.wsgi.application' % SITE_NAME ########## END WSGI CONFIGURATION -########## LDAP SETTINGS -GROUP_BASE_DN = get_env_setting('GVALDAP_BASEDN_GROUP') -USER_BASE_DN = get_env_setting('GVALDAP_BASEDN_USER') -########## END LDAP SETTINGS +# ######### LDAP SETTINGS +GROUP_BASE_DN = get_env_variable('GVALDAP_BASEDN_GROUP') +USER_BASE_DN = get_env_variable('GVALDAP_BASEDN_USER') +# ######### END LDAP SETTINGS ########## CELERY CONFIGURATION -BROKER_URL = get_env_setting('GVALDAP_BROKER_URL') -CELERY_RESULT_BACKEND = 'amqp' +BROKER_URL = get_env_variable('GVALDAP_BROKER_URL') +CELERY_RESULT_BACKEND = 'rpc://' CELERY_RESULT_PERSISTENT = True CELERY_TASK_RESULT_EXPIRES = None CELERY_ROUTES = ( @@ -296,6 +296,6 @@ CELERY_ROUTES = ( CELERY_TIMEZONE = 'Europe/Berlin' CELERY_ENABLE_UTC = True CELERY_ACCEPT_CONTENT = ['json'] -CELERY_TASK_SERAILIZER = 'json' +CELERY_TASK_SERIALIZER = 'json' CELERY_RESULT_SERIALIZER = 'json' ########## END CELERY CONFIGURATION diff --git a/gvaldap/gvaldap/settings/production.py b/gvaldap/gvaldap/settings/production.py index e24de0d..c8eb1f4 100644 --- a/gvaldap/gvaldap/settings/production.py +++ b/gvaldap/gvaldap/settings/production.py @@ -10,7 +10,7 @@ from .base import * ########## HOST CONFIGURATION # See: https://docs.djangoproject.com/en/1.5/releases/1.5/#allowed-hosts-required-in-production -ALLOWED_HOSTS = get_env_setting('GVALDAP_ALLOWED_HOSTS').split(',') +ALLOWED_HOSTS = get_env_variable('GVALDAP_ALLOWED_HOSTS').split(',') ########## END HOST CONFIGURATION ########## EMAIL CONFIGURATION @@ -36,7 +36,7 @@ EMAIL_SUBJECT_PREFIX = '[%s] ' % SITE_NAME #EMAIL_USE_TLS = True # See: https://docs.djangoproject.com/en/dev/ref/settings/#server-email -SERVER_EMAIL = get_env_setting('GVALDAP_SERVER_EMAIL') +SERVER_EMAIL = get_env_variable('GVALDAP_SERVER_EMAIL') ########## END EMAIL CONFIGURATION ########## DATABASE CONFIGURATION