summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2015-06-05 14:13:03 +0100
committerAlexandru DAMIAN <alexandru.damian@intel.com>2015-06-10 15:31:12 +0100
commit26dc19284e06a7ae35f75a243b2062f61e30f2ca (patch)
tree37961a5ceade301501eb6c995b90281e2e7d0e5b /lib
parentfb683135348b074412da154585c75865aad1eab0 (diff)
downloadbitbake-contrib-26dc19284e06a7ae35f75a243b2062f61e30f2ca.tar.gz
toaster: toastertables raise errors
Modifies the widget code to raise the Exceptions to the user instead of printing then to stdout - making the programming errors much more visible. Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/toaster/toastergui/widgets.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/toaster/toastergui/widgets.py b/lib/toaster/toastergui/widgets.py
index 407a0fbe1..3d3c1d10d 100644
--- a/lib/toaster/toastergui/widgets.py
+++ b/lib/toaster/toastergui/widgets.py
@@ -207,7 +207,8 @@ class ToasterTable(TemplateView):
try:
self.filter_actions[filter_action]()
except KeyError:
- print "Filter and Filter action pair not found"
+ # pass it to the user - programming error here
+ raise
def apply_orderby(self, orderby):
# Note that django will execute this when we try to retrieve the data
@@ -217,8 +218,7 @@ class ToasterTable(TemplateView):
"""Creates a query based on the model's search_allowed_fields"""
if not hasattr(self.queryset.model, 'search_allowed_fields'):
- print "Err Search fields aren't defined in the model"
- return
+ raise Exception("Err Search fields aren't defined in the model")
search_queries = []
for st in search_term.split(" "):
@@ -228,9 +228,10 @@ class ToasterTable(TemplateView):
search_queries.append(reduce(operator.or_, q_map))
search_queries = reduce(operator.and_, search_queries)
- print "applied the search to the queryset"
+
self.queryset = self.queryset.filter(search_queries)
+
def get_data(self, request, **kwargs):
"""Returns the data for the page requested with the specified
parameters applied"""
@@ -318,7 +319,8 @@ class ToasterTable(TemplateView):
data['rows'].append(required_data)
except FieldError:
- print "Error: Requested field does not exist"
+ # pass it to the user - programming-error here
+ raise
data = json.dumps(data, indent=2, default=objtojson)
cache.set(cache_name, data, 60*30)