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.
This commit is contained in:
Jan Dittberner 2016-01-31 16:32:14 +01:00
parent 02768a4b95
commit 5094990c9a
2 changed files with 20 additions and 20 deletions

View file

@ -5,28 +5,28 @@ Common settings and globals.
""" """
from os import environ
from os.path import abspath, basename, dirname, join, normpath from os.path import abspath, basename, dirname, join, normpath
from sys import path from sys import path
from os import environ
# Normally you should not import ANYTHING from Django directly # Normally you should not import ANYTHING from Django directly
# into your settings, but ImproperlyConfigured is an exception. # into your settings, but ImproperlyConfigured is an exception.
from django.core.exceptions import ImproperlyConfigured 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 :raises ImproperlyConfigured: if the environment setting is not defined
:return: environment setting value :return: environment setting value
:rtype: str :rtype: str
""" """
try: try:
return environ[setting] return environ[var_name]
except KeyError: except KeyError:
error_msg = "Set the %s env variable" % setting error_msg = "Set the %s environment variable" % var_name
raise ImproperlyConfigured(error_msg) raise ImproperlyConfigured(error_msg)
@ -58,7 +58,7 @@ TEMPLATE_DEBUG = DEBUG
########## MANAGER CONFIGURATION ########## MANAGER CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#admins # See: https://docs.djangoproject.com/en/dev/ref/settings/#admins
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 # See: https://docs.djangoproject.com/en/dev/ref/settings/#managers
@ -79,9 +79,9 @@ DATABASES = {
}, },
'ldap': { 'ldap': {
'ENGINE': 'ldapdb.backends.ldap', 'ENGINE': 'ldapdb.backends.ldap',
'NAME': get_env_setting('GVALDAP_LDAP_URL'), 'NAME': get_env_variable('GVALDAP_LDAP_URL'),
'USER': get_env_setting('GVALDAP_LDAP_USER'), 'USER': get_env_variable('GVALDAP_LDAP_USER'),
'PASSWORD': get_env_setting('GVALDAP_LDAP_PASSWORD'), 'PASSWORD': get_env_variable('GVALDAP_LDAP_PASSWORD'),
} }
} }
DATABASE_ROUTERS = ['ldapdb.router.Router'] DATABASE_ROUTERS = ['ldapdb.router.Router']
@ -141,7 +141,7 @@ STATICFILES_FINDERS = (
########## SECRET CONFIGURATION ########## SECRET CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key # See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
# Note: This key should only be used for development and testing. # 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 ########## END SECRET CONFIGURATION
@ -279,15 +279,15 @@ WSGI_APPLICATION = '%s.wsgi.application' % SITE_NAME
########## END WSGI CONFIGURATION ########## END WSGI CONFIGURATION
########## LDAP SETTINGS # ######### LDAP SETTINGS
GROUP_BASE_DN = get_env_setting('GVALDAP_BASEDN_GROUP') GROUP_BASE_DN = get_env_variable('GVALDAP_BASEDN_GROUP')
USER_BASE_DN = get_env_setting('GVALDAP_BASEDN_USER') USER_BASE_DN = get_env_variable('GVALDAP_BASEDN_USER')
########## END LDAP SETTINGS # ######### END LDAP SETTINGS
########## CELERY CONFIGURATION ########## CELERY CONFIGURATION
BROKER_URL = get_env_setting('GVALDAP_BROKER_URL') BROKER_URL = get_env_variable('GVALDAP_BROKER_URL')
CELERY_RESULT_BACKEND = 'amqp' CELERY_RESULT_BACKEND = 'rpc://'
CELERY_RESULT_PERSISTENT = True CELERY_RESULT_PERSISTENT = True
CELERY_TASK_RESULT_EXPIRES = None CELERY_TASK_RESULT_EXPIRES = None
CELERY_ROUTES = ( CELERY_ROUTES = (
@ -296,6 +296,6 @@ CELERY_ROUTES = (
CELERY_TIMEZONE = 'Europe/Berlin' CELERY_TIMEZONE = 'Europe/Berlin'
CELERY_ENABLE_UTC = True CELERY_ENABLE_UTC = True
CELERY_ACCEPT_CONTENT = ['json'] CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERAILIZER = 'json' CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json' CELERY_RESULT_SERIALIZER = 'json'
########## END CELERY CONFIGURATION ########## END CELERY CONFIGURATION

View file

@ -10,7 +10,7 @@ from .base import *
########## HOST CONFIGURATION ########## HOST CONFIGURATION
# See: https://docs.djangoproject.com/en/1.5/releases/1.5/#allowed-hosts-required-in-production # 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 ########## END HOST CONFIGURATION
########## EMAIL CONFIGURATION ########## EMAIL CONFIGURATION
@ -36,7 +36,7 @@ EMAIL_SUBJECT_PREFIX = '[%s] ' % SITE_NAME
#EMAIL_USE_TLS = True #EMAIL_USE_TLS = True
# See: https://docs.djangoproject.com/en/dev/ref/settings/#server-email # 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 ########## END EMAIL CONFIGURATION
########## DATABASE CONFIGURATION ########## DATABASE CONFIGURATION