summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastermain
diff options
context:
space:
mode:
authorDavid Reyna <David.Reyna@windriver.com>2017-06-27 13:44:28 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-06-28 16:02:15 +0100
commitd74bcbeaf241a67871d62b7e2c17900ae900642e (patch)
treebd0bf6037a0de26e7668f146ec6ff4afde07e54f /bitbake/lib/toaster/toastermain
parentc3058ec4a4f2f4c57116816a5bede1e61a5a4cc4 (diff)
downloadpoky-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')
-rw-r--r--bitbake/lib/toaster/toastermain/management/commands/buildslist.py6
-rw-r--r--bitbake/lib/toaster/toastermain/settings.py70
-rw-r--r--bitbake/lib/toaster/toastermain/urls.py8
3 files changed, 49 insertions, 35 deletions
diff --git a/bitbake/lib/toaster/toastermain/management/commands/buildslist.py b/bitbake/lib/toaster/toastermain/management/commands/buildslist.py
index 8dfef0aa00..70b5812d98 100644
--- a/bitbake/lib/toaster/toastermain/management/commands/buildslist.py
+++ b/bitbake/lib/toaster/toastermain/management/commands/buildslist.py
@@ -1,13 +1,13 @@
1from django.core.management.base import NoArgsCommand, CommandError 1from django.core.management.base import BaseCommand, CommandError
2from orm.models import Build 2from orm.models import Build
3import os 3import os
4 4
5 5
6 6
7class Command(NoArgsCommand): 7class Command(BaseCommand):
8 args = "" 8 args = ""
9 help = "Lists current builds" 9 help = "Lists current builds"
10 10
11 def handle_noargs(self,**options): 11 def handle(self,**options):
12 for b in Build.objects.all(): 12 for b in Build.objects.all():
13 print("%d: %s %s %s" % (b.pk, b.machine, b.distro, ",".join([x.target for x in b.target_set.all()]))) 13 print("%d: %s %s %s" % (b.pk, b.machine, b.distro, ",".join([x.target for x in b.target_set.all()])))
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 @@
24import os 24import os
25 25
26DEBUG = True 26DEBUG = True
27TEMPLATE_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
30SQL_DEBUG = False 29SQL_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.
162SECRET_KEY = 'NOT_SUITABLE_FOR_HOSTED_DEPLOYMENT' 161SECRET_KEY = 'NOT_SUITABLE_FOR_HOSTED_DEPLOYMENT'
163 162
164# List of callables that know how to import templates from various sources. 163class InvalidString(str):
165TEMPLATE_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
169TEMPLATES = [
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
171MIDDLEWARE_CLASSES = ( 205MIDDLEWARE_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.
204WSGI_APPLICATION = 'toastermain.wsgi.application' 238WSGI_APPLICATION = 'toastermain.wsgi.application'
205 239
206TEMPLATE_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
212TEMPLATE_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
223INSTALLED_APPS = ( 241INSTALLED_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
351class 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
357TEMPLATE_STRING_IF_INVALID = InvalidString("%s")
diff --git a/bitbake/lib/toaster/toastermain/urls.py b/bitbake/lib/toaster/toastermain/urls.py
index 1f8599edc3..bb325596bb 100644
--- a/bitbake/lib/toaster/toastermain/urls.py
+++ b/bitbake/lib/toaster/toastermain/urls.py
@@ -23,6 +23,8 @@ from django.conf.urls import patterns, include, url
23from django.views.generic import RedirectView 23from django.views.generic import RedirectView
24from django.views.decorators.cache import never_cache 24from django.views.decorators.cache import never_cache
25 25
26import bldcollector.views
27
26import logging 28import logging
27 29
28logger = logging.getLogger("toaster") 30logger = logging.getLogger("toaster")
@@ -31,7 +33,7 @@ logger = logging.getLogger("toaster")
31from django.contrib import admin 33from django.contrib import admin
32admin.autodiscover() 34admin.autodiscover()
33 35
34urlpatterns = patterns('', 36urlpatterns = [
35 37
36 # Examples: 38 # Examples:
37 # url(r'^toaster/', include('toaster.foo.urls')), 39 # url(r'^toaster/', include('toaster.foo.urls')),
@@ -42,11 +44,11 @@ urlpatterns = patterns('',
42 44
43 # This is here to maintain backward compatibility and will be deprecated 45 # This is here to maintain backward compatibility and will be deprecated
44 # in the future. 46 # in the future.
45 url(r'^orm/eventfile$', 'bldcollector.views.eventfile'), 47 url(r'^orm/eventfile$', bldcollector.views.eventfile),
46 48
47 # if no application is selected, we have the magic toastergui app here 49 # if no application is selected, we have the magic toastergui app here
48 url(r'^$', never_cache(RedirectView.as_view(url='/toastergui/', permanent=True))), 50 url(r'^$', never_cache(RedirectView.as_view(url='/toastergui/', permanent=True))),
49) 51]
50 52
51import toastermain.settings 53import toastermain.settings
52 54