mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-19 21:17:54 +00:00
Rename web CheckResults to -Renderer, to avoid confusion. Closes #1705.
This avoids the name collision between the actual results objects (defined in allmydata.check_results) and the code that renders these objects into HTML (defined in allmydata.web.check_results). Only the web-side objects were renamed.
This commit is contained in:
parent
3a2a086f6c
commit
bf390cca4b
@ -43,7 +43,7 @@ class WebResultsRendering(unittest.TestCase, WebRenderingMixin):
|
|||||||
|
|
||||||
def test_literal(self):
|
def test_literal(self):
|
||||||
c = self.create_fake_client()
|
c = self.create_fake_client()
|
||||||
lcr = web_check_results.LiteralCheckResults(c)
|
lcr = web_check_results.LiteralCheckResultsRenderer(c)
|
||||||
|
|
||||||
d = self.render1(lcr)
|
d = self.render1(lcr)
|
||||||
def _check(html):
|
def _check(html):
|
||||||
@ -88,7 +88,7 @@ class WebResultsRendering(unittest.TestCase, WebRenderingMixin):
|
|||||||
}
|
}
|
||||||
cr.set_data(data)
|
cr.set_data(data)
|
||||||
|
|
||||||
w = web_check_results.CheckResults(c, cr)
|
w = web_check_results.CheckResultsRenderer(c, cr)
|
||||||
html = self.render2(w)
|
html = self.render2(w)
|
||||||
s = self.remove_tags(html)
|
s = self.remove_tags(html)
|
||||||
self.failUnlessIn("File Check Results for SI=2k6avp", s) # abbreviated
|
self.failUnlessIn("File Check Results for SI=2k6avp", s) # abbreviated
|
||||||
@ -211,7 +211,7 @@ class WebResultsRendering(unittest.TestCase, WebRenderingMixin):
|
|||||||
crr.post_repair_results = post_cr
|
crr.post_repair_results = post_cr
|
||||||
crr.repair_attempted = False
|
crr.repair_attempted = False
|
||||||
|
|
||||||
w = web_check_results.CheckAndRepairResults(c, crr)
|
w = web_check_results.CheckAndRepairResultsRenderer(c, crr)
|
||||||
html = self.render2(w)
|
html = self.render2(w)
|
||||||
s = self.remove_tags(html)
|
s = self.remove_tags(html)
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ class WebResultsRendering(unittest.TestCase, WebRenderingMixin):
|
|||||||
self.failUnlessEqual(j["post-repair-results"]["summary"], "worse")
|
self.failUnlessEqual(j["post-repair-results"]["summary"], "worse")
|
||||||
d.addCallback(_got_json)
|
d.addCallback(_got_json)
|
||||||
|
|
||||||
w2 = web_check_results.CheckAndRepairResults(c, None)
|
w2 = web_check_results.CheckAndRepairResultsRenderer(c, None)
|
||||||
d.addCallback(lambda ignored: self.render_json(w2))
|
d.addCallback(lambda ignored: self.render_json(w2))
|
||||||
def _got_lit_results(data):
|
def _got_lit_results(data):
|
||||||
j = simplejson.loads(data)
|
j = simplejson.loads(data)
|
||||||
|
@ -185,7 +185,7 @@ class ResultsBase:
|
|||||||
target = target + "?output=%s" % output
|
target = target + "?output=%s" % output
|
||||||
return T.a(href=target)[si_s]
|
return T.a(href=target)[si_s]
|
||||||
|
|
||||||
class LiteralCheckResults(rend.Page, ResultsBase):
|
class LiteralCheckResultsRenderer(rend.Page, ResultsBase):
|
||||||
docFactory = getxmlfile("literal-check-results.xhtml")
|
docFactory = getxmlfile("literal-check-results.xhtml")
|
||||||
|
|
||||||
def __init__(self, client):
|
def __init__(self, client):
|
||||||
@ -226,7 +226,7 @@ class CheckerBase:
|
|||||||
return T.div[T.a(href=return_to)["Return to file/directory."]]
|
return T.div[T.a(href=return_to)["Return to file/directory."]]
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
class CheckResults(CheckerBase, rend.Page, ResultsBase):
|
class CheckResultsRenderer(CheckerBase, rend.Page, ResultsBase):
|
||||||
docFactory = getxmlfile("check-results.xhtml")
|
docFactory = getxmlfile("check-results.xhtml")
|
||||||
|
|
||||||
def __init__(self, client, results):
|
def __init__(self, client, results):
|
||||||
@ -269,7 +269,7 @@ class CheckResults(CheckerBase, rend.Page, ResultsBase):
|
|||||||
cr = self._render_results(ctx, data)
|
cr = self._render_results(ctx, data)
|
||||||
return ctx.tag[cr]
|
return ctx.tag[cr]
|
||||||
|
|
||||||
class CheckAndRepairResults(CheckerBase, rend.Page, ResultsBase):
|
class CheckAndRepairResultsRenderer(CheckerBase, rend.Page, ResultsBase):
|
||||||
docFactory = getxmlfile("check-and-repair-results.xhtml")
|
docFactory = getxmlfile("check-and-repair-results.xhtml")
|
||||||
|
|
||||||
def __init__(self, client, results):
|
def __init__(self, client, results):
|
||||||
@ -316,7 +316,7 @@ class CheckAndRepairResults(CheckerBase, rend.Page, ResultsBase):
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
class DeepCheckResults(rend.Page, ResultsBase, ReloadMixin):
|
class DeepCheckResultsRenderer(rend.Page, ResultsBase, ReloadMixin):
|
||||||
docFactory = getxmlfile("deep-check-results.xhtml")
|
docFactory = getxmlfile("deep-check-results.xhtml")
|
||||||
|
|
||||||
def __init__(self, client, monitor):
|
def __init__(self, client, monitor):
|
||||||
@ -331,7 +331,7 @@ class DeepCheckResults(rend.Page, ResultsBase, ReloadMixin):
|
|||||||
si = base32.a2b(name)
|
si = base32.a2b(name)
|
||||||
r = self.monitor.get_status()
|
r = self.monitor.get_status()
|
||||||
try:
|
try:
|
||||||
return CheckResults(self.client,
|
return CheckResultsRenderer(self.client,
|
||||||
r.get_results_for_storage_index(si))
|
r.get_results_for_storage_index(si))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise WebError("No detailed results for SI %s" % html.escape(name),
|
raise WebError("No detailed results for SI %s" % html.escape(name),
|
||||||
@ -470,7 +470,7 @@ class DeepCheckResults(rend.Page, ResultsBase, ReloadMixin):
|
|||||||
runtime = time.time() - req.processing_started_timestamp
|
runtime = time.time() - req.processing_started_timestamp
|
||||||
return ctx.tag["runtime: %s seconds" % runtime]
|
return ctx.tag["runtime: %s seconds" % runtime]
|
||||||
|
|
||||||
class DeepCheckAndRepairResults(rend.Page, ResultsBase, ReloadMixin):
|
class DeepCheckAndRepairResultsRenderer(rend.Page, ResultsBase, ReloadMixin):
|
||||||
docFactory = getxmlfile("deep-check-and-repair-results.xhtml")
|
docFactory = getxmlfile("deep-check-and-repair-results.xhtml")
|
||||||
|
|
||||||
def __init__(self, client, monitor):
|
def __init__(self, client, monitor):
|
||||||
@ -483,10 +483,10 @@ class DeepCheckAndRepairResults(rend.Page, ResultsBase, ReloadMixin):
|
|||||||
# /operation/$OPHANDLE/$STORAGEINDEX provides detailed information
|
# /operation/$OPHANDLE/$STORAGEINDEX provides detailed information
|
||||||
# about a specific file or directory that was checked
|
# about a specific file or directory that was checked
|
||||||
si = base32.a2b(name)
|
si = base32.a2b(name)
|
||||||
r = self.monitor.get_status()
|
s = self.monitor.get_status()
|
||||||
try:
|
try:
|
||||||
return CheckAndRepairResults(self.client,
|
results = s.get_results_for_storage_index(si)
|
||||||
r.get_results_for_storage_index(si))
|
return CheckAndRepairResultsRenderer(self.client, results)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise WebError("No detailed results for SI %s" % html.escape(name),
|
raise WebError("No detailed results for SI %s" % html.escape(name),
|
||||||
http.NOT_FOUND)
|
http.NOT_FOUND)
|
||||||
|
@ -28,9 +28,9 @@ from allmydata.web.common import text_plain, WebError, \
|
|||||||
get_format, get_mutable_type
|
get_format, get_mutable_type
|
||||||
from allmydata.web.filenode import ReplaceMeMixin, \
|
from allmydata.web.filenode import ReplaceMeMixin, \
|
||||||
FileNodeHandler, PlaceHolderNodeHandler
|
FileNodeHandler, PlaceHolderNodeHandler
|
||||||
from allmydata.web.check_results import CheckResults, \
|
from allmydata.web.check_results import CheckResultsRenderer, \
|
||||||
CheckAndRepairResults, DeepCheckResults, DeepCheckAndRepairResults, \
|
CheckAndRepairResultsRenderer, DeepCheckResultsRenderer, \
|
||||||
LiteralCheckResults
|
DeepCheckAndRepairResultsRenderer, LiteralCheckResultsRenderer
|
||||||
from allmydata.web.info import MoreInfo
|
from allmydata.web.info import MoreInfo
|
||||||
from allmydata.web.operations import ReloadMixin
|
from allmydata.web.operations import ReloadMixin
|
||||||
from allmydata.web.check_results import json_check_results, \
|
from allmydata.web.check_results import json_check_results, \
|
||||||
@ -421,7 +421,7 @@ class DirectoryNodeHandler(RenderMixin, rend.Page, ReplaceMeMixin):
|
|||||||
def _maybe_literal(self, res, Results_Class):
|
def _maybe_literal(self, res, Results_Class):
|
||||||
if res:
|
if res:
|
||||||
return Results_Class(self.client, res)
|
return Results_Class(self.client, res)
|
||||||
return LiteralCheckResults(self.client)
|
return LiteralCheckResultsRenderer(self.client)
|
||||||
|
|
||||||
def _POST_check(self, req):
|
def _POST_check(self, req):
|
||||||
# check this directory
|
# check this directory
|
||||||
@ -430,10 +430,10 @@ class DirectoryNodeHandler(RenderMixin, rend.Page, ReplaceMeMixin):
|
|||||||
add_lease = boolean_of_arg(get_arg(req, "add-lease", "false"))
|
add_lease = boolean_of_arg(get_arg(req, "add-lease", "false"))
|
||||||
if repair:
|
if repair:
|
||||||
d = self.node.check_and_repair(Monitor(), verify, add_lease)
|
d = self.node.check_and_repair(Monitor(), verify, add_lease)
|
||||||
d.addCallback(self._maybe_literal, CheckAndRepairResults)
|
d.addCallback(self._maybe_literal, CheckAndRepairResultsRenderer)
|
||||||
else:
|
else:
|
||||||
d = self.node.check(Monitor(), verify, add_lease)
|
d = self.node.check(Monitor(), verify, add_lease)
|
||||||
d.addCallback(self._maybe_literal, CheckResults)
|
d.addCallback(self._maybe_literal, CheckResultsRenderer)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def _start_operation(self, monitor, renderer, ctx):
|
def _start_operation(self, monitor, renderer, ctx):
|
||||||
@ -450,10 +450,10 @@ class DirectoryNodeHandler(RenderMixin, rend.Page, ReplaceMeMixin):
|
|||||||
add_lease = boolean_of_arg(get_arg(ctx, "add-lease", "false"))
|
add_lease = boolean_of_arg(get_arg(ctx, "add-lease", "false"))
|
||||||
if repair:
|
if repair:
|
||||||
monitor = self.node.start_deep_check_and_repair(verify, add_lease)
|
monitor = self.node.start_deep_check_and_repair(verify, add_lease)
|
||||||
renderer = DeepCheckAndRepairResults(self.client, monitor)
|
renderer = DeepCheckAndRepairResultsRenderer(self.client, monitor)
|
||||||
else:
|
else:
|
||||||
monitor = self.node.start_deep_check(verify, add_lease)
|
monitor = self.node.start_deep_check(verify, add_lease)
|
||||||
renderer = DeepCheckResults(self.client, monitor)
|
renderer = DeepCheckResultsRenderer(self.client, monitor)
|
||||||
return self._start_operation(monitor, renderer, ctx)
|
return self._start_operation(monitor, renderer, ctx)
|
||||||
|
|
||||||
def _POST_stream_deep_check(self, ctx):
|
def _POST_stream_deep_check(self, ctx):
|
||||||
|
@ -19,8 +19,8 @@ from allmydata.web.common import text_plain, WebError, RenderMixin, \
|
|||||||
boolean_of_arg, get_arg, should_create_intermediate_directories, \
|
boolean_of_arg, get_arg, should_create_intermediate_directories, \
|
||||||
MyExceptionHandler, parse_replace_arg, parse_offset_arg, \
|
MyExceptionHandler, parse_replace_arg, parse_offset_arg, \
|
||||||
get_format, get_mutable_type
|
get_format, get_mutable_type
|
||||||
from allmydata.web.check_results import CheckResults, \
|
from allmydata.web.check_results import CheckResultsRenderer, \
|
||||||
CheckAndRepairResults, LiteralCheckResults
|
CheckAndRepairResultsRenderer, LiteralCheckResultsRenderer
|
||||||
from allmydata.web.info import MoreInfo
|
from allmydata.web.info import MoreInfo
|
||||||
|
|
||||||
class ReplaceMeMixin:
|
class ReplaceMeMixin:
|
||||||
@ -285,7 +285,7 @@ class FileNodeHandler(RenderMixin, rend.Page, ReplaceMeMixin):
|
|||||||
def _maybe_literal(self, res, Results_Class):
|
def _maybe_literal(self, res, Results_Class):
|
||||||
if res:
|
if res:
|
||||||
return Results_Class(self.client, res)
|
return Results_Class(self.client, res)
|
||||||
return LiteralCheckResults(self.client)
|
return LiteralCheckResultsRenderer(self.client)
|
||||||
|
|
||||||
def _POST_check(self, req):
|
def _POST_check(self, req):
|
||||||
verify = boolean_of_arg(get_arg(req, "verify", "false"))
|
verify = boolean_of_arg(get_arg(req, "verify", "false"))
|
||||||
@ -293,10 +293,10 @@ class FileNodeHandler(RenderMixin, rend.Page, ReplaceMeMixin):
|
|||||||
add_lease = boolean_of_arg(get_arg(req, "add-lease", "false"))
|
add_lease = boolean_of_arg(get_arg(req, "add-lease", "false"))
|
||||||
if repair:
|
if repair:
|
||||||
d = self.node.check_and_repair(Monitor(), verify, add_lease)
|
d = self.node.check_and_repair(Monitor(), verify, add_lease)
|
||||||
d.addCallback(self._maybe_literal, CheckAndRepairResults)
|
d.addCallback(self._maybe_literal, CheckAndRepairResultsRenderer)
|
||||||
else:
|
else:
|
||||||
d = self.node.check(Monitor(), verify, add_lease)
|
d = self.node.check(Monitor(), verify, add_lease)
|
||||||
d.addCallback(self._maybe_literal, CheckResults)
|
d.addCallback(self._maybe_literal, CheckResultsRenderer)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def render_DELETE(self, ctx):
|
def render_DELETE(self, ctx):
|
||||||
|
Loading…
Reference in New Issue
Block a user