From ed18c4a6f9225e30f5dd5b58f210a5026d6cce80 Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Sun, 31 Jan 2016 23:19:26 +0100 Subject: [PATCH] Modernize dependencies, sync with gva This commit modernizes all requirements to the latest versions, adapts the settings to Django 1.9 and synchronizes the settings layout with gva. --- .gitignore | 1 + gvaldap/gvacommon/.gitignore | 3 -- gvaldap/gvacommon/__init__.py | 0 gvaldap/gvacommon/celeryrouters.py | 15 ------ gvaldap/gvaldap/settings/base.py | 69 ++++++++++++-------------- gvaldap/gvaldap/settings/local.py | 33 ++++++++---- gvaldap/gvaldap/settings/production.py | 41 +++++---------- gvaldap/gvaldap/settings/test.py | 9 ++-- gvaldap/gvaldap/urls.py | 16 +++--- requirements/base.txt | 24 ++++++--- requirements/local.txt | 12 +++-- requirements/test.txt | 2 +- 12 files changed, 105 insertions(+), 120 deletions(-) delete mode 100644 gvaldap/gvacommon/.gitignore delete mode 100644 gvaldap/gvacommon/__init__.py delete mode 100644 gvaldap/gvacommon/celeryrouters.py diff --git a/.gitignore b/.gitignore index fcd5c5c..debdad8 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ Desktop.ini .ropeproject _build/ .vagrant/ +.coverage diff --git a/gvaldap/gvacommon/.gitignore b/gvaldap/gvacommon/.gitignore deleted file mode 100644 index 5f1ace6..0000000 --- a/gvaldap/gvacommon/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.*.swp -*.pyc -.ropeproject/ diff --git a/gvaldap/gvacommon/__init__.py b/gvaldap/gvacommon/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/gvaldap/gvacommon/celeryrouters.py b/gvaldap/gvacommon/celeryrouters.py deleted file mode 100644 index ec7b122..0000000 --- a/gvaldap/gvacommon/celeryrouters.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - - -class GvaRouter(object): - - def route_for_task(self, task, args=None, kwargs=None): - for route in ['ldap', 'file', 'mysql', 'pgsql']: - if route in task: - return { - 'exchange': route, - 'exchange_type': 'direct', - 'queue': route, - } - return None diff --git a/gvaldap/gvaldap/settings/base.py b/gvaldap/gvaldap/settings/base.py index dbe55a8..f03937e 100644 --- a/gvaldap/gvaldap/settings/base.py +++ b/gvaldap/gvaldap/settings/base.py @@ -50,9 +50,6 @@ path.append(DJANGO_ROOT) # See: https://docs.djangoproject.com/en/dev/ref/settings/#debug DEBUG = False -# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug -TEMPLATE_DEBUG = DEBUG -########## END DEBUG CONFIGURATION ########## MANAGER CONFIGURATION @@ -119,20 +116,11 @@ MEDIA_URL = '/media/' ########## STATIC FILE CONFIGURATION -# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-root -STATIC_ROOT = normpath(join(SITE_ROOT, 'assets')) - # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url STATIC_URL = '/static/' -# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS -STATICFILES_DIRS = ( - normpath(join(SITE_ROOT, 'static')), -) - # See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders STATICFILES_FINDERS = ( - 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ) ########## END STATIC FILE CONFIGURATION @@ -161,28 +149,29 @@ FIXTURE_DIRS = ( ########## TEMPLATE CONFIGURATION -# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors -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.static', - 'django.core.context_processors.tz', - 'django.contrib.messages.context_processors.messages', - 'django.core.context_processors.request', -) +# See: https://docs.djangoproject.com/en/1.9/ref/settings/#std:setting-TEMPLATES # noqa +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [ + normpath(join(SITE_ROOT, 'templates')), + ], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.contrib.auth.context_processors.auth', + 'django.template.context_processors.debug', + 'django.template.context_processors.i18n', + 'django.template.context_processors.media', + 'django.template.context_processors.static', + 'django.template.context_processors.tz', + 'django.contrib.messages.context_processors.messages', + 'django.template.context_processors.request', + ], + }, + }, +] -# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders -TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', -) - -# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs -TEMPLATE_DIRS = ( - normpath(join(SITE_ROOT, 'templates')), -) ########## END TEMPLATE CONFIGURATION @@ -195,6 +184,7 @@ MIDDLEWARE_CLASSES = ( 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.locale.LocaleMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) ########## END MIDDLEWARE CONFIGURATION @@ -221,12 +211,8 @@ DJANGO_APPS = ( 'django.contrib.messages', 'django.contrib.staticfiles', - # Useful template tags: - # 'django.contrib.humanize', - # Admin panel and documentation: 'django.contrib.admin', - # 'django.contrib.admindocs', ) # Apps specific for this project go here. @@ -250,6 +236,15 @@ INSTALLED_APPS = DJANGO_APPS + LOCAL_APPS LOGGING = { 'version': 1, 'disable_existing_loggers': False, + 'formatters': { + 'verbose': { + 'format': '%(levelname)s %(asctime)s %(name)s ' + '%(module)s:%(lineno)d %(process)d %(thread)d %(message)s', + }, + 'simple': { + 'format': '%(levelname)s %(name)s:%(lineno)d %(message)s', + }, + }, 'filters': { 'require_debug_false': { '()': 'django.utils.log.RequireDebugFalse' diff --git a/gvaldap/gvaldap/settings/local.py b/gvaldap/gvaldap/settings/local.py index 8a8d441..d0d8fef 100644 --- a/gvaldap/gvaldap/settings/local.py +++ b/gvaldap/gvaldap/settings/local.py @@ -1,3 +1,4 @@ +# -*- python -*- # pymode:lint_ignore=W0401,E501 """ Development settings and globals based on :py:mod:`gvaldap.settings.base`. @@ -6,32 +7,33 @@ Development settings and globals based on :py:mod:`gvaldap.settings.base`. from __future__ import absolute_import -from .base import * +# use import * to import all settings from base +from .base import * # NOQA -########## DEBUG CONFIGURATION +# ######### DEBUG CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#debug DEBUG = True # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug -TEMPLATE_DEBUG = DEBUG -########## END DEBUG CONFIGURATION +TEMPLATES[0]['OPTIONS']['debug'] = DEBUG +# ######### END DEBUG CONFIGURATION -########## EMAIL CONFIGURATION +# ######### EMAIL CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' -########## END EMAIL CONFIGURATION +# ######### END EMAIL CONFIGURATION -########## CACHE CONFIGURATION +# ######### CACHE CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#caches CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', } } -########## END CACHE CONFIGURATION +# ######### END CACHE CONFIGURATION ########## TOOLBAR CONFIGURATION @@ -44,8 +46,19 @@ MIDDLEWARE_CLASSES += ( 'debug_toolbar.middleware.DebugToolbarMiddleware', ) +LOGGING['handlers'].update({ + 'console': { + 'level': 'DEBUG', + 'class': 'logging.StreamHandler', + 'formatter': 'simple', + } +}) +LOGGING['loggers'].update(dict( + [(key, {'handlers': ['console'], 'level': 'DEBUG', 'propagate': True, }) + for key in ['ldapentities', 'ldaptasks']])) + DEBUG_TOOLBAR_PATCH_SETTINGS = False # http://django-debug-toolbar.readthedocs.org/en/latest/installation.html -INTERNAL_IPS = ('127.0.0.1',) -########## END TOOLBAR CONFIGURATION +INTERNAL_IPS = ('127.0.0.1', '10.0.2.2') +# ######### END TOOLBAR CONFIGURATION diff --git a/gvaldap/gvaldap/settings/production.py b/gvaldap/gvaldap/settings/production.py index c8eb1f4..03d35a2 100644 --- a/gvaldap/gvaldap/settings/production.py +++ b/gvaldap/gvaldap/settings/production.py @@ -1,3 +1,4 @@ +# -*- python -*- # pymode:lint_ignore=W0401,E501 """ Production settings and globals based on :py:mod:`gvaldap.settings.base`. @@ -6,45 +7,29 @@ Production settings and globals based on :py:mod:`gvaldap.settings.base`. from __future__ import absolute_import -from .base import * +# use import * to import all settings from base +from .base import * # NOQA -########## HOST CONFIGURATION -# See: https://docs.djangoproject.com/en/1.5/releases/1.5/#allowed-hosts-required-in-production +# ######### HOST CONFIGURATION +# See: https://docs.djangoproject.com/en/1.5/releases/1.5/#allowed-hosts-required-in-production # noqa ALLOWED_HOSTS = get_env_variable('GVALDAP_ALLOWED_HOSTS').split(',') -########## END HOST CONFIGURATION +# ######### END HOST CONFIGURATION -########## EMAIL CONFIGURATION +# ######### EMAIL CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-backend EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' -# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host -#EMAIL_HOST = environ.get('EMAIL_HOST', 'smtp.gmail.com') - -# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-password -#EMAIL_HOST_PASSWORD = environ.get('EMAIL_HOST_PASSWORD', '') - -# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-host-user -#EMAIL_HOST_USER = environ.get('EMAIL_HOST_USER', 'your_email@example.com') - -# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-port -#EMAIL_PORT = environ.get('EMAIL_PORT', 587) - # See: https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix EMAIL_SUBJECT_PREFIX = '[%s] ' % SITE_NAME -# See: https://docs.djangoproject.com/en/dev/ref/settings/#email-use-tls -#EMAIL_USE_TLS = True +# See: https://docs.djangoproject.com/en/dev/ref/settings/#default-from-email +DEFAULT_FROM_EMAIL = get_env_variable('GVALDAP_ADMIN_EMAIL') # See: https://docs.djangoproject.com/en/dev/ref/settings/#server-email SERVER_EMAIL = get_env_variable('GVALDAP_SERVER_EMAIL') -########## END EMAIL CONFIGURATION +# ######### END EMAIL CONFIGURATION -########## DATABASE CONFIGURATION -#DATABASES = {} -########## END DATABASE CONFIGURATION - - -########## CACHE CONFIGURATION +# ######### CACHE CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#caches -#CACHES = {} -########## END CACHE CONFIGURATION +# CACHES = {} +# ######### END CACHE CONFIGURATION diff --git a/gvaldap/gvaldap/settings/test.py b/gvaldap/gvaldap/settings/test.py index dc5d82b..b83ae47 100644 --- a/gvaldap/gvaldap/settings/test.py +++ b/gvaldap/gvaldap/settings/test.py @@ -8,6 +8,9 @@ from __future__ import absolute_import # use import * to import all settings from base from .base import * # NOQA +PASSWORD_HASHERS = ( + 'django.contrib.auth.hashers.MD5PasswordHasher', +) ########## IN-MEMORY TEST DATABASE DATABASES = { "default": { @@ -28,10 +31,6 @@ LOGGING['handlers'].update({ }) LOGGING['loggers'].update(dict( [(key, {'handlers': ['console'], 'level': 'ERROR', 'propagate': True, }) - for key in [ - 'dashboard', 'domains', 'fileservertasks', 'gvacommon', - 'gvawebcore', 'hostingpackages', 'ldaptasks', 'managemails', - 'mysqltasks', 'osusers', 'pgsqltasks', 'taskresults', - 'userdbs', 'websites']])) + for key in ['ldapentities', 'ldaptasks']])) BROKER_URL = BROKER_URL + '_test' CELERY_RESULT_PERSISTENT = False diff --git a/gvaldap/gvaldap/urls.py b/gvaldap/gvaldap/urls.py index ca59fb7..1ca71d4 100644 --- a/gvaldap/gvaldap/urls.py +++ b/gvaldap/gvaldap/urls.py @@ -3,23 +3,21 @@ This module defines the main URLConf for gvaldap. """ -from django.conf.urls import patterns, include, url +from django.conf.urls import include, url from django.conf import settings -# Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() -urlpatterns = patterns( - '', +urlpatterns = [ url(r'^admin/', include(admin.site.urls)), -) +] # Uncomment the next line to serve media files in dev. # urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) -if settings.DEBUG: +if settings.DEBUG: # pragma: no cover import debug_toolbar - urlpatterns += patterns('', - url(r'^__debug__/', include(debug_toolbar.urls)), - ) + urlpatterns += [ + url(r'^__debug__/', include(debug_toolbar.urls)), + ] diff --git a/requirements/base.txt b/requirements/base.txt index 0f0c966..72a3736 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,10 +1,20 @@ -Django==1.7.4 -django-ldapdb==0.3.2 -bpython==0.13.2 -django-braces==1.4.0 -django-model-utils==2.2 +Django==1.9.1 +Jinja2==2.8 +#django-ldapdb==0.4.0 +-e git+https://github.com/jandd/django-ldapdb@django19#egg=django-ldapdb +python-ldap==2.4.25 +bpython==0.15 +curtsies==0.2.6 +django-braces==1.8.1 +django-model-utils==2.4 logutils==0.3.3 celery==3.1.20 -passlib==1.6.2 -requests==2.5.1 +amqp==1.4.9 +billiard==3.3.0.22 +kombu==3.0.33 +pytz==2015.7 +passlib==1.6.5 +requests==2.9.1 +simplejson==3.8.1 +-e git+https://git.gnuviech-server.de/gvacommon.git@0.2.1#egg=gvacommon redis==2.10.5 diff --git a/requirements/local.txt b/requirements/local.txt index 0b60d4a..e7f6872 100644 --- a/requirements/local.txt +++ b/requirements/local.txt @@ -1,10 +1,12 @@ # Local development dependencies go here -r test.txt -django-debug-toolbar==1.2.2 -Sphinx==1.2.3 -sqlparse==0.1.14 -releases==0.7.0 -Pygments==2.0.2 +django-debug-toolbar==1.4 +sqlparse==0.1.18 +Sphinx==1.3.5 +Babel==2.2.0 +snowballstemmer==1.2.1 +releases==1.0.0 +Pygments==2.1 flake8==2.5.2 mccabe==0.4.0 pep8==1.7.0 diff --git a/requirements/test.txt b/requirements/test.txt index bb78fde..47897db 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,3 +1,3 @@ # Test dependencies go here. -r base.txt -coverage==3.7.1 +coverage==4.0.3