bitbake: toastergui: Fix toastertable table header reference
PATCH 1/3 bitbake: toastergui: Fix toastertable table header reference
A header id was mistakenly added to the table template which was not also added to the simple version of the toaster template. We don't need this id so remove it.
--- bitbake/lib/toaster/toastergui/static/js/table.js | 2 +- bitbake/lib/toaster/toastergui/templates/toastertable.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
bitbake/lib/toaster/toastergui/static/js/table.js +1 -1
@@ -198,7 +198,7 @@ function tableInit(ctx){ if (tableChromeDone === true) return; - var tableHeadRow = table.find("thead#tableheader"); + var tableHeadRow = table.find("thead"); var editColMenu = $("#table-chrome-"+ctx.tableName).find(".editcol"); tableHeadRow.html("");
bitbake/lib/toaster/toastergui/templates/toastertable.html +1 -1
@@ -78,7 +78,7 @@ <!-- The actual table --> <table class="table table-bordered table-hover tablesorter" id="{{table_name}}"> - <thead id="tableheader"> + <thead> <tr><th></th></tr> </thead> <tbody></tbody>
Signature · 1 line
2.1.4
PATCH 2/3 bitbake: toastergui: Move layerdetails view definition to the views.py
The layerdetails view definition was moved to tables though it isn't a table. We have a mechanism for the JSON response for this page so use this instead of a custom class.
--- bitbake/lib/toaster/toastergui/tables.py | 24 +----------------------- bitbake/lib/toaster/toastergui/urls.py | 3 +-- bitbake/lib/toaster/toastergui/views.py | 15 +++++++++++++++ bitbake/lib/toaster/toastergui/widgets.py | 26 -------------------------- 4 files changed, 17 insertions(+), 51 deletions(-)
bitbake/lib/toaster/toastergui/tables.py +1 -23
@@ -19,7 +19,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -from toastergui.widgets import ToasterTable, ToasterTemplateView +from toastergui.widgets import ToasterTable from orm.models import Recipe, ProjectLayer, Layer_Version, Machine, Project from django.db.models import Q, Max from django.conf.urls import url
@@ -202,28 +202,6 @@ class LayersTable(ToasterTable): computation = lambda x: x.layer.name) - - -class LayerDetails(ToasterTemplateView): - def get_context_data(self, **kwargs): - context = super(LayerDetails, self).get_context_data(**kwargs) - from toastergui.views import _lv_to_dict - - context['project'] = Project.objects.get(pk=kwargs['pid']) - context['layerversion'] = Layer_Version.objects.get(pk=kwargs['layerid']) - context['layerdict'] = _lv_to_dict(context['project'], context['layerversion']) - context['layerdeps'] = {"list": [ - [ {"id": y.id, - "name": y.layer.name, - "layerdetailurl": reverse('layerdetails', args=(kwargs['pid'], y.id)), - } for y in x.depends_on.get_equivalents_wpriority(context['project'])][0] for x in context['layerversion'].dependencies.all()]} - context['projectlayers'] = map(lambda prjlayer: prjlayer.layercommit.id, ProjectLayer.objects.filter(project=context['project'])) - - self.context_entries = ['project', 'layerversion', 'projectlayers', 'layerdict', 'layerdeps'] - - return context - - class MachinesTable(ToasterTable, ProjectFiltersMixin): """Table of Machines in Toaster"""
bitbake/lib/toaster/toastergui/urls.py +1 -2
@@ -109,8 +109,7 @@ urlpatterns = patterns('toastergui.views', name="projectlayers"), url(r'^project/(?P<pid>\d+)/layer/(?P<layerid>\d+)$', - tables.LayerDetails.as_view(template_name='layerdetails.html'), - name='layerdetails'), + 'layerdetails', name='layerdetails'), url(r'^project/(?P<pid>\d+)/layer/(?P<layerid>\d+)/recipes/$', tables.LayerRecipesTable.as_view(template_name="generic-toastertable-page.html"),
bitbake/lib/toaster/toastergui/views.py +15 -0
@@ -2528,6 +2528,21 @@ if True: } return render(request, template, context) + @_template_renderer('layerdetails.html') + def layerdetails(request, pid, layerid): + project = Project.objects.get(pk=pid) + layer_version = Layer_Version.objects.get(pk=layerid) + + context = { 'project' : project, + 'layerversion' : layer_version, + 'layerdeps' : { "list": [ + [{"id": y.id, "name": y.layer.name} for y in x.depends_on.get_equivalents_wpriority(project)][0] for x in layer_version.dependencies.all()]}, + 'projectlayers': map(lambda prjlayer: prjlayer.layercommit.id, ProjectLayer.objects.filter(project=project)) + } + + return context + + def get_project_configvars_context(): # Vars managed outside of this view vars_managed = {
bitbake/lib/toaster/toastergui/widgets.py +0 -26
@@ -328,29 +328,3 @@ class ToasterTable(TemplateView): cache.set(cache_name, data, 60*30) return data - - -class ToasterTemplateView(TemplateView): - # renders a instance in a template, or returns the context as json - # the class-equivalent of the _template_renderer decorator for views - - - def get(self, *args, **kwargs): - if self.request.GET.get('format', None) == 'json': - from django.core.urlresolvers import reverse - from django.shortcuts import HttpResponse - from views import objtojson - from toastergui.templatetags.projecttags import json as jsonfilter - - context = self.get_context_data(**kwargs) - - for x in context.keys(): - if x not in self.context_entries: - del context[x] - - context["error"] = "ok" - - return HttpResponse(jsonfilter(context, default=objtojson ), - content_type = "application/json; charset=utf-8") - - return super(ToasterTemplateView, self).get(*args, **kwargs)
Signature · 1 line
2.1.4
PATCH 3/3 bitbake: toastermain: Add a longer default database timeout
In reply to Michael WoodWhen using sqlite we sometimes see Database Locked exceptions when we fire off database calls asynchronously from the UI. We need sqlite to wait a bit longer for the lock to be released.
n.b In production setup we hopefully wouldn't be using sqlite.
docs.djangoproject.com/en/1.6/ref/databases/#database-is-locked-errors
--- bitbake/lib/toaster/toastermain/settings.py | 6 ++++++ 1 file changed, 6 insertions(+)
bitbake/lib/toaster/toastermain/settings.py +6 -0
@@ -49,6 +49,12 @@ DATABASES = { } } +# Needed when Using sqlite especially to add a longer timeout for waiting +# for the database lock to be released +# https://docs.djangoproject.com/en/1.6/ref/databases/#database-is-locked-errors +if 'sqlite' in DATABASES['default']['ENGINE']: + DATABASES['default']['OPTIONS'] = { 'timeout': 20 } + # Reinterpret database settings if we have DATABASE_URL environment variable defined if 'DATABASE_URL' in os.environ:
Signature · 1 line
2.1.4
Re: [review-request][PATCH 3/3] bitbake: toastermain: Add a longer default database timeout
Should have mentioned that this is a v2 series of
https://lists.yoctoproject.org/pipermail/toaster/2015-July/002428.html
https://lists.yoctoproject.org/pipermail/toaster/2015-July/002429.html
https://lists.yoctoproject.org/pipermail/toaster/2015-July/002430.html
Which is now rebased and with the fixes for review items mentioned by Ed
Michael
Quoted 29 lines · Michael Wood
When using sqlite we sometimes see Database Locked exceptions when we fire off database calls asynchronously from the UI. We need sqlite to wait a bit longer for the lock to be released.
n.b In production setup we hopefully wouldn't be using sqlite.docs.djangoproject.com/en/1.6/ref/databases/#database-is-locked-errors
Signed-off-by Michael Wood <[email protected]>--- bitbake/lib/toaster/toastermain/settings.py | 6 ++++++ 1 file changed, 6 insertions(+)bitbake/lib/toaster/toastermain/settings.py +6
-0@@ -49,6 +49,12 @@ DATABASES = { } } +# Needed when Using sqlite especially to add a longer timeout for waiting +# for the database lock to be released +# https://docs.djangoproject.com/en/1.6/ref/databases/#database-is-locked-errors +if 'sqlite' in DATABASES['default']['ENGINE']: + DATABASES['default']['OPTIONS'] = { 'timeout': 20 } + # Reinterpret database settings if we have DATABASE_URL environment variable defined if 'DATABASE_URL' in os.environ: