[PATCH] Be still more careful with "opts" in koji-web.

Ralph Bean rbean at redhat.com
Sat May 9 23:36:09 UTC 2015


And add some comments to this section so that future readers will understand
all the gymnastics.
---
 www/lib/kojiweb/util.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/www/lib/kojiweb/util.py b/www/lib/kojiweb/util.py
index 6610beb..7f7b578 100644
--- a/www/lib/kojiweb/util.py
+++ b/www/lib/kojiweb/util.py
@@ -463,10 +463,16 @@ def taskScratchClass(task_object):
     """ Return a css class indicating whether or not this task is a scratch
     build.
     """
+    # Here, we try to figure out if this is supposed to be a scratch task based
+    # on this 'request' list attached to the task object.  It's hard to know
+    # exactly what's in it, because it's an unstructured list.  Different kinds
+    # of tasks stuff different things in it in different places.
     request = task_object['request']
     if len(request) >= 3:
         opts = request[2]
-        if opts and opts.get('scratch'):
+        # This is tough, because "opts" could be a one of a number of different
+        # things.  A dict, a bool, None, etc..
+        if hasattr(opts, 'get') and opts.get('scratch'):
             return "scratch"
     return ""
 
-- 
2.1.0



More information about the buildsys mailing list