[PATCH] Be still more careful with "opts" in koji-web.
Mike McLean
mikem at redhat.com
Mon May 11 17:32:36 UTC 2015
On 05/09/2015 07:36 PM, Ralph Bean wrote:
> 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.
Sorry I hadn't gotten around to reviewing the earlier patch.
If you're going to dig through the task request, you should most likely
be checking the task method first. Checking for a minimum request length
is not really a sufficient check.
Every task method has its own signature, some of which have changed over
time.
> 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 ""
>
>
More information about the buildsys
mailing list