Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 90943E00DE8; Thu, 26 May 2016 08:13:15 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low * trust * [209.85.192.176 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily * valid * -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Received: from mail-pf0-f176.google.com (mail-pf0-f176.google.com [209.85.192.176]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 49793E00DCA for ; Thu, 26 May 2016 08:12:48 -0700 (PDT) Received: by mail-pf0-f176.google.com with SMTP id g64so32020791pfb.2 for ; Thu, 26 May 2016 08:12:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rMidclnD8Urop8A3xBROjM4oj/xstnUmd/jgvHbmDMc=; b=DBiSiJEUcL+tANy4RTRZCPv2C+fPv6xo9voXA/mM1/iwVuoS+EGZqO24BPCRA/ZgB7 AEQYl2nQt0GLDJ4gJ/+QtDrZChLWFTsThOkm0yzYdnNl9T2IbNF+72R54F8eYOhcQ9n6 tOljiSrOU9FDUsFOra6/vkhCYPk1GWUOWxbrDtPc6/HFLc547+jMfoiQK66ht5y6JpIX aVYSCR1oOrxC0ivnO1Cxg36FreIlm78SrPJ5SIdvOlkv19/dd5wKl5wnfSAt/mJNKzvY uqIjmQiYbKpXLSiAArOwz1pY1Y059CUJZjkW9nWexPfQaK0W3dGAtPtXHksKolE8G5j0 E4dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rMidclnD8Urop8A3xBROjM4oj/xstnUmd/jgvHbmDMc=; b=Z7MqLws8kb8qvGi3WF4xaVdL+t7LK9pptvqR116LooQLVgYng1fqmC124ZlehMFYMF lk3rgmGugsgijs4xBQQxl3PYkokJOw5msM3kqLIUignM0pAMWDlh/hEn1NTILqi5kvzW mOgpA4eaPLZVxYOqNNZ7BLGKDbyHLEp4hV9MsKP7nDqSiysDSFaUinpmoEuVjysHk6F1 AJTRZIMaHtjDuRf/R1B+AvtYr8sFSQpdsMaxZlciUWm3QZZOcUDHl9jfHB/gcqIA07DY ZeyTGaeW8QhFlFfesx5nJ6sze32mTjs7jwcRbcR3hYhZJVDon/0IspugjaV8noi3hdki aJlg== X-Gm-Message-State: ALyK8tKcKvM406BnbxotGxWf1Hh+gv50zZBG0CrVw6G6qd0pYSVn1XXEzeNmOY8eGEF4NDrY X-Received: by 10.98.65.92 with SMTP id o89mr14028329pfa.72.1464275568005; Thu, 26 May 2016 08:12:48 -0700 (PDT) Received: from orion.ger.corp.intel.com ([192.55.54.45]) by smtp.gmail.com with ESMTPSA id l67sm6888008pfi.10.2016.05.26.08.12.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 May 2016 08:12:47 -0700 (PDT) From: Michael Wood To: toaster@yoctoproject.org Date: Thu, 26 May 2016 16:12:26 +0100 Message-Id: <1464275547-30446-9-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1464275547-30446-1-git-send-email-michael.g.wood@intel.com> References: <1464275547-30446-1-git-send-email-michael.g.wood@intel.com> Subject: [PATCH v2 8/9] toaster: widgets ToasterTable Catch template rendering exceptions X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 May 2016 15:13:15 -0000 If a cell template rendering causes an exception catch it and carry on, this at least allows the table to show the rest of the data if nothing else. Also improve the error logging so that it's possible what the offending template snippet was. Signed-off-by: Michael Wood --- bitbake/lib/toaster/toastergui/widgets.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/bitbake/lib/toaster/toastergui/widgets.py b/bitbake/lib/toaster/toastergui/widgets.py index 17c97fd..55ff33a 100644 --- a/bitbake/lib/toaster/toastergui/widgets.py +++ b/bitbake/lib/toaster/toastergui/widgets.py @@ -29,6 +29,8 @@ from django.core.paginator import Paginator, EmptyPage from django.db.models import Q from orm.models import Project, ProjectLayer, Layer_Version from django.template import Context, Template +from django.template import VariableDoesNotExist +from django.template import TemplateSyntaxError from django.core.serializers.json import DjangoJSONEncoder from django.core.exceptions import FieldError from django.conf.urls import url, patterns @@ -338,10 +340,20 @@ class ToasterTable(TemplateView): # so that this can be used as the html class name col['field_name'] = col['static_data_name'] - # Render the template given - required_data[col['static_data_name']] = \ - self.render_static_data( - col['static_data_template'], model_obj) + try: + # Render the template given + required_data[col['static_data_name']] = \ + self.render_static_data( + col['static_data_template'], model_obj) + except (TemplateSyntaxError, + VariableDoesNotExist) as e: + logger.error("could not render template code" + "%s %s %s", + col['static_data_template'], + e, self.__class__.__name__) + required_data[col['static_data_name']] =\ + '' + else: # Traverse to any foriegn key in the field # e.g. recipe__layer_version__name -- 2.7.4