Author: tmckay Date: 2011-07-20 17:30:59 +0000 (Wed, 20 Jul 2011) New Revision: 4877
Modified: trunk/cumin/python/cumin/grid/job.py Log: * Report errors for type mismatches on attribute edits. These errors were previously generated but not reported, and actually the occurrence of an error would leave the page in "Loading..." after submit
* Do not automatically add quotes to string attribute values. Adding quotes allowed users to edit Args without providing explicit quotes, but it broke attributes with expression values like Requirements. BZ703196 (backout automatic quoting) BZ723613
Modified: trunk/cumin/python/cumin/grid/job.py =================================================================== --- trunk/cumin/python/cumin/grid/job.py 2011-07-18 16:29:58 UTC (rev 4876) +++ trunk/cumin/python/cumin/grid/job.py 2011-07-20 17:30:59 UTC (rev 4877) @@ -729,6 +729,7 @@
just_ads = dict() for field in ads: + ads[field]["error"] = None try: fval = ads[field]["value"] except KeyError: @@ -757,23 +758,21 @@ elif ftype == "float": orig = float(orig) if fval != orig: - if ftype == "string": - quoted = ""%s"" % strip_string_quotes(fval) - if quoted == orig: - continue - just_ads[unicode(field)] = quoted #string - else: - just_ads[unicode(field)] = fval + if ftype == "string" and \ + strip_string_quotes(fval) == strip_string_quotes(orig): + continue + just_ads[unicode(field)] = fval
- if not errors: - id = self.frame.id.get(session) - scheduler = self.frame.get_scheduler(session, id) - job_id = self.frame.job_id.get(session) + # Process all cases, including errors, becase we + # want to see a banner for errors we detect. + id = self.frame.id.get(session) + scheduler = self.frame.get_scheduler(session, id) + job_id = self.frame.job_id.get(session)
- task = self.frame.set_ad_task - for field in just_ads: - task.invoke(session, scheduler, job_id, field, str(just_ads[field])) - self.process_cancel(session) + task = self.frame.set_ad_task + for field in just_ads: + task.invoke(session, scheduler, job_id, field, str(just_ads[field]), ads[field]["error"]) + self.process_cancel(session)
class OutputFile(Widget): err_msg = "Output, Error, and UserLog file names are invalid." @@ -1063,7 +1062,12 @@ def get_description(self, session): return "Edit Ad"
- def do_invoke(self, invoc, scheduler, job_id, name, value): - self.app.remote.set_job_attribute(scheduler, job_id, name, value, - invoc.make_callback()) + def do_invoke(self, invoc, scheduler, job_id, name, value, error): + # Don't make the call, but we want to see the banner + # so invoke the callback directly with the error as status + if error: + invoc.make_callback()(name + ": " + str(error), None) + else: + self.app.remote.set_job_attribute(scheduler, job_id, name, value, + invoc.make_callback())