From d2a704c075668c592030638d94a3829ae1a47a0f Mon Sep 17 00:00:00 2001 From: Martin Mahner Date: Wed, 23 Mar 2016 14:02:19 +0100 Subject: [PATCH] Code Updates for Django 1.8+ --- dpaste/settings/base.py | 20 ++++++++++++++------ dpaste/urls/__init__.py | 10 ++++------ dpaste/urls/dpaste.py | 26 ++++++++++++++------------ dpaste/urls/dpaste_api.py | 4 ++-- 4 files changed, 34 insertions(+), 26 deletions(-) diff --git a/dpaste/settings/base.py b/dpaste/settings/base.py index 488aee4..c0f27b2 100644 --- a/dpaste/settings/base.py +++ b/dpaste/settings/base.py @@ -25,7 +25,6 @@ if not os.path.exists(VAR_ROOT): #============================================================================== DEBUG = False -TEMPLATE_DEBUG = DEBUG # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name @@ -95,15 +94,24 @@ MIDDLEWARE_CLASSES = ( 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) -TEMPLATE_CONTEXT_PROCESSORS += ( - 'django.core.context_processors.request', - 'django.core.context_processors.i18n', -) + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + ], + }, + }, +] INSTALLED_APPS = ( 'django.contrib.staticfiles', 'django.contrib.sessions', - 'mptt', 'gunicorn', 'dpaste', diff --git a/dpaste/urls/__init__.py b/dpaste/urls/__init__.py index 4ae40ff..721a00e 100644 --- a/dpaste/urls/__init__.py +++ b/dpaste/urls/__init__.py @@ -1,12 +1,10 @@ -from django.conf.urls import url, patterns, include +from django.conf.urls import url, include -urlpatterns = patterns( - '', +urlpatterns = [ url(r'^', include('dpaste.urls.dpaste_api')), url(r'^', include('dpaste.urls.dpaste')), - - (r'^i18n/', include('django.conf.urls.i18n')), -) + url(r'^i18n/', include('django.conf.urls.i18n')), +] # Custom error handlers which load `dpaste/.html` instead of `.html` handler404 = 'dpaste.views.page_not_found' diff --git a/dpaste/urls/dpaste.py b/dpaste/urls/dpaste.py index d074234..20713a5 100644 --- a/dpaste/urls/dpaste.py +++ b/dpaste/urls/dpaste.py @@ -1,17 +1,19 @@ from django.conf import settings -from django.conf.urls import patterns, url +from django.conf.urls import url + +from .. import views L = getattr(settings, 'DPASTE_SLUG_LENGTH', 4) -urlpatterns = patterns('dpaste.views', - url(r'^about/$', 'about', name='dpaste_about'), +urlpatterns = [ + url(r'^about/$', views.about, name='dpaste_about'), - url(r'^$', 'snippet_new', name='snippet_new'), - url(r'^diff/$', 'snippet_diff', name='snippet_diff'), - url(r'^history/$', 'snippet_history', name='snippet_history'), - url(r'^delete/$', 'snippet_delete', name='snippet_delete'), - url(r'^(?P[a-zA-Z0-9]{%d,})/?$' % L, 'snippet_details', name='snippet_details'), - url(r'^(?P[a-zA-Z0-9]{%d,})/delete/$' % L, 'snippet_delete', name='snippet_delete'), - url(r'^(?P[a-zA-Z0-9]{%d,})/gist/$' % L, 'snippet_gist', name='snippet_gist'), - url(r'^(?P[a-zA-Z0-9]{%d,})/raw/?$' % L, 'snippet_details', {'template_name': 'dpaste/snippet_details_raw.html', 'is_raw': True}, name='snippet_details_raw'), -) + url(r'^$', views.snippet_new, name='snippet_new'), + url(r'^diff/$', views.snippet_diff, name='snippet_diff'), + url(r'^history/$', views.snippet_history, name='snippet_history'), + url(r'^delete/$', views.snippet_delete, name='snippet_delete'), + url(r'^(?P[a-zA-Z0-9]{%d,})/?$' % L, views.snippet_details, name='snippet_details'), + url(r'^(?P[a-zA-Z0-9]{%d,})/delete/$' % L, views.snippet_delete, name='snippet_delete'), + url(r'^(?P[a-zA-Z0-9]{%d,})/gist/$' % L, views.snippet_gist, name='snippet_gist'), + url(r'^(?P[a-zA-Z0-9]{%d,})/raw/?$' % L, views.snippet_details, {'template_name': 'dpaste/snippet_details_raw.html', 'is_raw': True}, name='snippet_details_raw'), +] diff --git a/dpaste/urls/dpaste_api.py b/dpaste/urls/dpaste_api.py index 3722851..df419e4 100644 --- a/dpaste/urls/dpaste_api.py +++ b/dpaste/urls/dpaste_api.py @@ -2,6 +2,6 @@ from django.conf.urls import patterns, url from ..views import snippet_api -urlpatterns = patterns('', +urlpatterns = [ url(r'^api/$', snippet_api, name='dpaste_api_create_snippet'), -) +]