Author: tmckay
Date: 2011-05-25 13:01:06 +0000 (Wed, 25 May 2011)
New Revision: 4784
Modified:
trunk/cumin/python/cumin/grid/job.py
trunk/cumin/python/cumin/objectselector.py
Log:
Suppress exceptions in ObjectSelectorTaskForm.get_selection() when looking up items.
Previously, an exception here would kill the task but leave the form displayed, with
no way out but to modify the URL by hand.
Additionaly, move form straight to cancel state if no items from the selection list are
found.
This prevents a form pop up on an empty selection list.
BZ659247
Modified: trunk/cumin/python/cumin/grid/job.py
===================================================================
--- trunk/cumin/python/cumin/grid/job.py 2011-05-24 20:28:55 UTC (rev 4783)
+++ trunk/cumin/python/cumin/grid/job.py 2011-05-25 13:01:06 UTC (rev 4784)
@@ -356,6 +356,7 @@
selection = list(ids)
self.selection.set(session, selection)
+ return len(selection)
def get_reason(self, session, verb):
""" returns <verb> by username[: <user input reason>]
"""
Modified: trunk/cumin/python/cumin/objectselector.py
===================================================================
--- trunk/cumin/python/cumin/objectselector.py 2011-05-24 20:28:55 UTC (rev 4783)
+++ trunk/cumin/python/cumin/objectselector.py 2011-05-25 13:01:06 UTC (rev 4784)
@@ -518,7 +518,10 @@
self.app.form_page.modes.add_mode(self)
def do_process(self, session):
- self.get_selection(session)
+ # If the selection list is zero length,
+ # set cancel state and let processing complete.
+ if self.get_selection(session) == 0:
+ self.cancel(session)
super(ObjectSelectorTaskForm, self).do_process(session)
def get_selection(self, session):
@@ -527,8 +530,12 @@
self.selection.set(session, selection)
for id in self.ids.get(session):
- item = self.cls.get_object_by_id(session.cursor, id)
- selection.append(item)
+ try:
+ item = self.cls.get_object_by_id(session.cursor, id)
+ selection.append(item)
+ except:
+ pass
+ return len(selection)
def process_submit(self, session):
selection = self.selection.get(session)
Show replies by thread