mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-30 01:38:55 +00:00
Merge pull request #727 from sajith/3315.operations-reload-mixin-nevow-to-twisted
Replace nevow with twisted.web in operations.ReloadMixin Fixes: ticket:3315
This commit is contained in:
commit
fe967d208b
1
newsfragments/3315.minor
Normal file
1
newsfragments/3315.minor
Normal file
@ -0,0 +1 @@
|
|||||||
|
Replace nevow with twisted.web in web.operations.ReloadMixin
|
@ -1,7 +1,11 @@
|
|||||||
|
|
||||||
import time
|
import time
|
||||||
from nevow import rend, url, tags as T
|
from nevow import rend, url
|
||||||
from nevow.inevow import IRequest
|
from nevow.inevow import IRequest
|
||||||
|
from twisted.web.template import (
|
||||||
|
renderer,
|
||||||
|
tags as T,
|
||||||
|
)
|
||||||
from twisted.python.failure import Failure
|
from twisted.python.failure import Failure
|
||||||
from twisted.internet import reactor, defer
|
from twisted.internet import reactor, defer
|
||||||
from twisted.web.http import NOT_FOUND
|
from twisted.web.http import NOT_FOUND
|
||||||
@ -122,31 +126,31 @@ class OphandleTable(rend.Page, service.Service):
|
|||||||
class ReloadMixin(object):
|
class ReloadMixin(object):
|
||||||
REFRESH_TIME = 1*MINUTE
|
REFRESH_TIME = 1*MINUTE
|
||||||
|
|
||||||
def render_refresh(self, ctx, data):
|
@renderer
|
||||||
|
def refresh(self, req, tag):
|
||||||
if self.monitor.is_finished():
|
if self.monitor.is_finished():
|
||||||
return ""
|
return ""
|
||||||
# dreid suggests ctx.tag(**dict([("http-equiv", "refresh")]))
|
# dreid suggests ctx.tag(**dict([("http-equiv", "refresh")]))
|
||||||
# but I can't tell if he's joking or not
|
# but I can't tell if he's joking or not
|
||||||
ctx.tag.attributes["http-equiv"] = "refresh"
|
tag.attributes["http-equiv"] = "refresh"
|
||||||
ctx.tag.attributes["content"] = str(self.REFRESH_TIME)
|
tag.attributes["content"] = str(self.REFRESH_TIME)
|
||||||
return ctx.tag
|
return tag
|
||||||
|
|
||||||
def render_reload(self, ctx, data):
|
@renderer
|
||||||
|
def reload(self, req, tag):
|
||||||
if self.monitor.is_finished():
|
if self.monitor.is_finished():
|
||||||
return ""
|
return ""
|
||||||
req = IRequest(ctx)
|
|
||||||
# url.gethere would break a proxy, so the correct thing to do is
|
# url.gethere would break a proxy, so the correct thing to do is
|
||||||
# req.path[-1] + queryargs
|
# req.path[-1] + queryargs
|
||||||
ophandle = req.prepath[-1]
|
ophandle = req.prepath[-1]
|
||||||
reload_target = ophandle + "?output=html"
|
reload_target = ophandle + "?output=html"
|
||||||
cancel_target = ophandle + "?t=cancel"
|
cancel_target = ophandle + "?t=cancel"
|
||||||
cancel_button = T.form(action=cancel_target, method="POST",
|
cancel_button = T.form(T.input(type="submit", value="Cancel"),
|
||||||
enctype="multipart/form-data")[
|
action=cancel_target,
|
||||||
T.input(type="submit", value="Cancel"),
|
method="POST",
|
||||||
]
|
enctype="multipart/form-data",)
|
||||||
|
|
||||||
return [T.h2["Operation still running: ",
|
return (T.h2("Operation still running: ",
|
||||||
T.a(href=reload_target)["Reload"],
|
T.a("Reload", href=reload_target),
|
||||||
],
|
),
|
||||||
cancel_button,
|
cancel_button,)
|
||||||
]
|
|
||||||
|
Loading…
Reference in New Issue
Block a user