diff options
author | David Reyna <David.Reyna@windriver.com> | 2017-06-27 13:44:28 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-06-28 16:02:15 +0100 |
commit | d74bcbeaf241a67871d62b7e2c17900ae900642e (patch) | |
tree | bd0bf6037a0de26e7668f146ec6ff4afde07e54f /bitbake/lib/toaster/toastermain/settings.py | |
parent | c3058ec4a4f2f4c57116816a5bede1e61a5a4cc4 (diff) | |
download | poky-d74bcbeaf241a67871d62b7e2c17900ae900642e.tar.gz |
bitbake: toaster: address Django-1.10 API deprecations
There are four main API deprecations in Django-1.10:
(a) String view arguments to url() must be replaced by
the explicit class reference
(b) New TEMPLATES stucture in settings.py consolidates
TEMPLATE_DIRS, TEMPLATE_CONTEXT_PROCESSORS,
TEMPLATE_LOADERS, TEMPLATE_STRING_IF_INVALID, and
TEMPLATE_DEBUG
(c) patterns() wrapper in url() is removed, with
urlpatterns now a simple list
(d) NoArgsCommand in commands() must be replace by
BaseCommand, and handle_noargs() changed to
handle()
Also, the Django version checker must be updated to accept
two digit sub-version numbers (e.g. "1.8" < "1.10")
[YOCTO #11684]
(Bitbake rev: e4c7a94fac7a53fc146387a57e5a09b9ec3caca0)
Signed-off-by: David Reyna <David.Reyna@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastermain/settings.py')
-rw-r--r-- | bitbake/lib/toaster/toastermain/settings.py | 70 |
1 files changed, 41 insertions, 29 deletions
diff --git a/bitbake/lib/toaster/toastermain/settings.py b/bitbake/lib/toaster/toastermain/settings.py index 1fd649c080..54ab31f302 100644 --- a/bitbake/lib/toaster/toastermain/settings.py +++ b/bitbake/lib/toaster/toastermain/settings.py | |||
@@ -24,7 +24,6 @@ | |||
24 | import os | 24 | import os |
25 | 25 | ||
26 | DEBUG = True | 26 | DEBUG = True |
27 | TEMPLATE_DEBUG = DEBUG | ||
28 | 27 | ||
29 | # Set to True to see the SQL queries in console | 28 | # Set to True to see the SQL queries in console |
30 | SQL_DEBUG = False | 29 | SQL_DEBUG = False |
@@ -161,12 +160,47 @@ STATICFILES_FINDERS = ( | |||
161 | # Make this unique, and don't share it with anybody. | 160 | # Make this unique, and don't share it with anybody. |
162 | SECRET_KEY = 'NOT_SUITABLE_FOR_HOSTED_DEPLOYMENT' | 161 | SECRET_KEY = 'NOT_SUITABLE_FOR_HOSTED_DEPLOYMENT' |
163 | 162 | ||
164 | # List of callables that know how to import templates from various sources. | 163 | class InvalidString(str): |
165 | TEMPLATE_LOADERS = ( | 164 | def __mod__(self, other): |
166 | 'django.template.loaders.filesystem.Loader', | 165 | from django.template.base import TemplateSyntaxError |
167 | 'django.template.loaders.app_directories.Loader', | 166 | raise TemplateSyntaxError( |
168 | # 'django.template.loaders.eggs.Loader', | 167 | "Undefined variable or unknown value for: \"%s\"" % other) |
169 | ) | 168 | |
169 | TEMPLATES = [ | ||
170 | { | ||
171 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||
172 | 'DIRS': [ | ||
173 | # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". | ||
174 | # Always use forward slashes, even on Windows. | ||
175 | # Don't forget to use absolute paths, not relative paths. | ||
176 | ], | ||
177 | 'OPTIONS': { | ||
178 | 'context_processors': [ | ||
179 | # Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this | ||
180 | # list if you haven't customized them: | ||
181 | 'django.contrib.auth.context_processors.auth', | ||
182 | 'django.template.context_processors.debug', | ||
183 | 'django.template.context_processors.i18n', | ||
184 | 'django.template.context_processors.media', | ||
185 | 'django.template.context_processors.static', | ||
186 | 'django.template.context_processors.tz', | ||
187 | 'django.contrib.messages.context_processors.messages', | ||
188 | # Custom | ||
189 | 'django.core.context_processors.request', | ||
190 | 'toastergui.views.managedcontextprocessor', | ||
191 | |||
192 | ], | ||
193 | 'loaders': [ | ||
194 | # List of callables that know how to import templates from various sources. | ||
195 | 'django.template.loaders.filesystem.Loader', | ||
196 | 'django.template.loaders.app_directories.Loader', | ||
197 | #'django.template.loaders.eggs.Loader', | ||
198 | ], | ||
199 | 'string_if_invalid': InvalidString("%s"), | ||
200 | 'debug': DEBUG, | ||
201 | }, | ||
202 | }, | ||
203 | ] | ||
170 | 204 | ||
171 | MIDDLEWARE_CLASSES = ( | 205 | MIDDLEWARE_CLASSES = ( |
172 | 'django.middleware.common.CommonMiddleware', | 206 | 'django.middleware.common.CommonMiddleware', |
@@ -203,22 +237,6 @@ ROOT_URLCONF = 'toastermain.urls' | |||
203 | # Python dotted path to the WSGI application used by Django's runserver. | 237 | # Python dotted path to the WSGI application used by Django's runserver. |
204 | WSGI_APPLICATION = 'toastermain.wsgi.application' | 238 | WSGI_APPLICATION = 'toastermain.wsgi.application' |
205 | 239 | ||
206 | TEMPLATE_DIRS = ( | ||
207 | # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". | ||
208 | # Always use forward slashes, even on Windows. | ||
209 | # Don't forget to use absolute paths, not relative paths. | ||
210 | ) | ||
211 | |||
212 | TEMPLATE_CONTEXT_PROCESSORS = ('django.contrib.auth.context_processors.auth', | ||
213 | 'django.core.context_processors.debug', | ||
214 | 'django.core.context_processors.i18n', | ||
215 | 'django.core.context_processors.media', | ||
216 | 'django.core.context_processors.static', | ||
217 | 'django.core.context_processors.tz', | ||
218 | 'django.contrib.messages.context_processors.messages', | ||
219 | "django.core.context_processors.request", | ||
220 | 'toastergui.views.managedcontextprocessor', | ||
221 | ) | ||
222 | 240 | ||
223 | INSTALLED_APPS = ( | 241 | INSTALLED_APPS = ( |
224 | 'django.contrib.auth', | 242 | 'django.contrib.auth', |
@@ -348,10 +366,4 @@ connection_created.connect(activate_synchronous_off) | |||
348 | # | 366 | # |
349 | 367 | ||
350 | 368 | ||
351 | class InvalidString(str): | ||
352 | def __mod__(self, other): | ||
353 | from django.template.base import TemplateSyntaxError | ||
354 | raise TemplateSyntaxError( | ||
355 | "Undefined variable or unknown value for: \"%s\"" % other) | ||
356 | 369 | ||
357 | TEMPLATE_STRING_IF_INVALID = InvalidString("%s") | ||