webish: tolerate not having a checker, since some unit tests don't make one

This commit is contained in:
Brian Warner 2007-10-23 17:35:31 -07:00
parent 046bda2b47
commit 42bd2bcf8e
1 changed files with 22 additions and 15 deletions

View File

@ -227,22 +227,29 @@ class Directory(rend.Page):
ctx.fillSlots("data", childdata) ctx.fillSlots("data", childdata)
checker = IClient(ctx).getServiceNamed("checker") try:
checker_results = checker.checker_results_for(target.get_verifier()) checker = IClient(ctx).getServiceNamed("checker")
recent_results = reversed(checker_results[-5:]) except KeyError:
if IFileNode.providedBy(target): checker = None
results = ("[" + if checker:
", ".join(["%d/%d" % (found, needed) checker_results = checker.checker_results_for(target.get_verifier())
for (when, (needed, total, found, sharemap)) recent_results = reversed(checker_results[-5:])
in recent_results]) + if IFileNode.providedBy(target):
"]") results = ("[" +
elif IDirectoryNode.providedBy(target): ", ".join(["%d/%d" % (found, needed)
results = ("[" + for (when,
"".join([{True:"+",False:"-"}[res] (needed, total, found, sharemap))
for (when, res) in recent_results]) + in recent_results]) +
"]") "]")
elif IDirectoryNode.providedBy(target):
results = ("[" +
"".join([{True:"+",False:"-"}[res]
for (when, res) in recent_results]) +
"]")
else:
results = "%d results" % len(checker_results)
else: else:
results = "%d results" % len(checker_results) results = "--"
ctx.fillSlots("checker_results", results) ctx.fillSlots("checker_results", results)
return ctx.tag return ctx.tag