2008-03-05 21:59:56 +00:00
|
|
|
|
2009-10-13 02:34:44 +00:00
|
|
|
import simplejson
|
2008-05-19 19:57:04 +00:00
|
|
|
from twisted.web import http, server
|
2009-06-25 02:17:07 +00:00
|
|
|
from twisted.python import log
|
2008-03-05 21:59:56 +00:00
|
|
|
from zope.interface import Interface
|
2008-05-19 19:57:04 +00:00
|
|
|
from nevow import loaders, appserver
|
|
|
|
from nevow.inevow import IRequest
|
2008-03-05 22:12:42 +00:00
|
|
|
from nevow.util import resource_filename
|
2011-08-24 15:59:28 +00:00
|
|
|
from allmydata import blacklist
|
2008-10-28 20:41:04 +00:00
|
|
|
from allmydata.interfaces import ExistingChildError, NoSuchChildError, \
|
2009-11-18 07:09:00 +00:00
|
|
|
FileTooLargeError, NotEnoughSharesError, NoSharesError, \
|
2010-01-27 06:44:30 +00:00
|
|
|
EmptyPathnameComponentError, MustBeDeepImmutableError, \
|
2011-08-07 00:43:48 +00:00
|
|
|
MustBeReadonlyError, MustNotBeUnknownRWError, SDMF_VERSION, MDMF_VERSION
|
2009-03-07 11:54:08 +00:00
|
|
|
from allmydata.mutable.common import UnrecoverableFileError
|
2010-07-11 19:55:25 +00:00
|
|
|
from allmydata.util import abbreviate
|
2011-01-22 01:40:06 +00:00
|
|
|
from allmydata.util.encodingutil import to_str, quote_output
|
|
|
|
|
2008-03-05 21:59:56 +00:00
|
|
|
|
2013-05-19 22:27:23 +00:00
|
|
|
TIME_FORMAT = "%H:%M:%S %d-%b-%Y"
|
|
|
|
|
2014-10-07 19:11:31 +00:00
|
|
|
def get_filenode_metadata(filenode):
|
2014-10-10 02:37:32 +00:00
|
|
|
metadata = {'mutable': filenode.is_mutable()}
|
2014-10-07 19:11:31 +00:00
|
|
|
if metadata['mutable']:
|
|
|
|
mutable_type = filenode.get_version()
|
|
|
|
assert mutable_type in (SDMF_VERSION, MDMF_VERSION)
|
|
|
|
if mutable_type == MDMF_VERSION:
|
|
|
|
file_format = "MDMF"
|
|
|
|
else:
|
|
|
|
file_format = "SDMF"
|
|
|
|
else:
|
|
|
|
file_format = "CHK"
|
|
|
|
metadata['format'] = file_format
|
2014-10-10 19:36:08 +00:00
|
|
|
size = filenode.get_size()
|
|
|
|
if size is not None:
|
|
|
|
metadata['size'] = size
|
2014-10-07 19:11:31 +00:00
|
|
|
return metadata
|
2013-05-19 22:27:23 +00:00
|
|
|
|
2008-10-22 00:03:07 +00:00
|
|
|
class IOpHandleTable(Interface):
|
|
|
|
pass
|
2008-03-05 22:12:42 +00:00
|
|
|
|
|
|
|
def getxmlfile(name):
|
|
|
|
return loaders.xmlfile(resource_filename('allmydata.web', '%s' % name))
|
|
|
|
|
|
|
|
def boolean_of_arg(arg):
|
2008-05-19 19:57:04 +00:00
|
|
|
# TODO: ""
|
2013-04-05 05:36:14 +00:00
|
|
|
if arg.lower() not in ("true", "t", "1", "false", "f", "0", "on", "off"):
|
|
|
|
raise WebError("invalid boolean argument: %r" % (arg,), http.BAD_REQUEST)
|
2008-03-05 22:12:42 +00:00
|
|
|
return arg.lower() in ("true", "t", "1", "on")
|
|
|
|
|
2009-07-20 03:47:23 +00:00
|
|
|
def parse_replace_arg(replace):
|
2009-07-20 15:38:03 +00:00
|
|
|
if replace.lower() == "only-files":
|
2009-07-20 03:47:23 +00:00
|
|
|
return replace
|
2013-04-05 05:36:14 +00:00
|
|
|
try:
|
2009-07-20 03:47:23 +00:00
|
|
|
return boolean_of_arg(replace)
|
2013-04-05 05:36:14 +00:00
|
|
|
except WebError:
|
|
|
|
raise WebError("invalid replace= argument: %r" % (replace,), http.BAD_REQUEST)
|
2009-07-20 03:47:23 +00:00
|
|
|
|
2011-08-07 00:43:48 +00:00
|
|
|
|
2011-10-13 16:29:51 +00:00
|
|
|
def get_format(req, default="CHK"):
|
|
|
|
arg = get_arg(req, "format", None)
|
2011-08-07 00:43:48 +00:00
|
|
|
if not arg:
|
2011-10-13 16:29:51 +00:00
|
|
|
if boolean_of_arg(get_arg(req, "mutable", "false")):
|
|
|
|
return "SDMF"
|
|
|
|
return default
|
|
|
|
if arg.upper() == "CHK":
|
|
|
|
return "CHK"
|
|
|
|
elif arg.upper() == "SDMF":
|
|
|
|
return "SDMF"
|
|
|
|
elif arg.upper() == "MDMF":
|
|
|
|
return "MDMF"
|
|
|
|
else:
|
|
|
|
raise WebError("Unknown format: %s, I know CHK, SDMF, MDMF" % arg,
|
|
|
|
http.BAD_REQUEST)
|
2011-08-07 00:43:48 +00:00
|
|
|
|
2011-10-13 16:29:51 +00:00
|
|
|
def get_mutable_type(file_format): # accepts result of get_format()
|
|
|
|
if file_format == "SDMF":
|
2011-08-07 00:43:48 +00:00
|
|
|
return SDMF_VERSION
|
2011-10-13 16:29:51 +00:00
|
|
|
elif file_format == "MDMF":
|
|
|
|
return MDMF_VERSION
|
|
|
|
else:
|
2011-10-13 16:32:29 +00:00
|
|
|
# this is also used to identify which formats are mutable. Use
|
|
|
|
# if get_mutable_type(file_format) is not None:
|
|
|
|
# do_mutable()
|
|
|
|
# else:
|
|
|
|
# do_immutable()
|
2011-10-13 16:29:51 +00:00
|
|
|
return None
|
2011-08-07 00:43:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
def parse_offset_arg(offset):
|
|
|
|
# XXX: This will raise a ValueError when invoked on something that
|
|
|
|
# is not an integer. Is that okay? Or do we want a better error
|
|
|
|
# message? Since this call is going to be used by programmers and
|
|
|
|
# their tools rather than users (through the wui), it is not
|
|
|
|
# inconsistent to return that, I guess.
|
|
|
|
if offset is not None:
|
|
|
|
offset = int(offset)
|
|
|
|
|
|
|
|
return offset
|
|
|
|
|
|
|
|
|
2008-10-22 00:03:07 +00:00
|
|
|
def get_root(ctx_or_req):
|
|
|
|
req = IRequest(ctx_or_req)
|
|
|
|
# the addSlash=True gives us one extra (empty) segment
|
|
|
|
depth = len(req.prepath) + len(req.postpath) - 1
|
|
|
|
link = "/".join([".."] * depth)
|
|
|
|
return link
|
|
|
|
|
|
|
|
def get_arg(ctx_or_req, argname, default=None, multiple=False):
|
2008-03-05 22:12:42 +00:00
|
|
|
"""Extract an argument from either the query args (req.args) or the form
|
|
|
|
body fields (req.fields). If multiple=False, this returns a single value
|
|
|
|
(or the default, which defaults to None), and the query args take
|
|
|
|
precedence. If multiple=True, this returns a tuple of arguments (possibly
|
|
|
|
empty), starting with all those in the query args.
|
|
|
|
"""
|
2008-10-22 00:03:07 +00:00
|
|
|
req = IRequest(ctx_or_req)
|
2008-03-05 22:12:42 +00:00
|
|
|
results = []
|
|
|
|
if argname in req.args:
|
|
|
|
results.extend(req.args[argname])
|
|
|
|
if req.fields and argname in req.fields:
|
|
|
|
results.append(req.fields[argname].value)
|
|
|
|
if multiple:
|
|
|
|
return tuple(results)
|
|
|
|
if results:
|
|
|
|
return results[0]
|
|
|
|
return default
|
2008-03-07 04:16:38 +00:00
|
|
|
|
2009-10-26 01:13:21 +00:00
|
|
|
def convert_children_json(nodemaker, children_json):
|
2009-10-17 19:28:29 +00:00
|
|
|
"""I convert the JSON output of GET?t=json into the dict-of-nodes input
|
|
|
|
to both dirnode.create_subdirectory() and
|
2009-11-18 07:09:00 +00:00
|
|
|
client.create_directory(initial_children=). This is used by
|
|
|
|
t=mkdir-with-children and t=mkdir-immutable"""
|
|
|
|
children = {}
|
2009-10-26 01:13:21 +00:00
|
|
|
if children_json:
|
|
|
|
data = simplejson.loads(children_json)
|
2010-07-11 19:55:25 +00:00
|
|
|
for (namex, (ctype, propdict)) in data.iteritems():
|
|
|
|
namex = unicode(namex)
|
|
|
|
writecap = to_str(propdict.get("rw_uri"))
|
|
|
|
readcap = to_str(propdict.get("ro_uri"))
|
2009-10-13 02:34:44 +00:00
|
|
|
metadata = propdict.get("metadata", {})
|
2010-07-11 19:55:25 +00:00
|
|
|
# name= argument is just for error reporting
|
|
|
|
childnode = nodemaker.create_from_cap(writecap, readcap, name=namex)
|
|
|
|
children[namex] = (childnode, metadata)
|
2009-11-18 07:09:00 +00:00
|
|
|
return children
|
2009-10-13 02:34:44 +00:00
|
|
|
|
2008-03-07 04:16:38 +00:00
|
|
|
def abbreviate_time(data):
|
|
|
|
# 1.23s, 790ms, 132us
|
|
|
|
if data is None:
|
|
|
|
return ""
|
|
|
|
s = float(data)
|
2009-03-07 05:45:17 +00:00
|
|
|
if s >= 10:
|
|
|
|
return abbreviate.abbreviate_time(data)
|
2008-03-07 04:16:38 +00:00
|
|
|
if s >= 1.0:
|
|
|
|
return "%.2fs" % s
|
|
|
|
if s >= 0.01:
|
2010-07-30 22:05:50 +00:00
|
|
|
return "%.0fms" % (1000*s)
|
2008-03-07 04:16:38 +00:00
|
|
|
if s >= 0.001:
|
|
|
|
return "%.1fms" % (1000*s)
|
2010-07-30 22:05:50 +00:00
|
|
|
return "%.0fus" % (1000000*s)
|
2008-03-07 04:16:38 +00:00
|
|
|
|
2010-08-15 14:19:33 +00:00
|
|
|
def compute_rate(bytes, seconds):
|
|
|
|
if bytes is None:
|
|
|
|
return None
|
|
|
|
|
|
|
|
if seconds is None or seconds == 0:
|
|
|
|
return None
|
|
|
|
|
|
|
|
# negative values don't make sense here
|
|
|
|
assert bytes > -1
|
|
|
|
assert seconds > 0
|
|
|
|
|
|
|
|
return 1.0 * bytes / seconds
|
|
|
|
|
2008-03-07 04:16:38 +00:00
|
|
|
def abbreviate_rate(data):
|
|
|
|
# 21.8kBps, 554.4kBps 4.37MBps
|
|
|
|
if data is None:
|
|
|
|
return ""
|
|
|
|
r = float(data)
|
|
|
|
if r > 1000000:
|
|
|
|
return "%1.2fMBps" % (r/1000000)
|
|
|
|
if r > 1000:
|
|
|
|
return "%.1fkBps" % (r/1000)
|
2010-07-30 22:05:50 +00:00
|
|
|
return "%.0fBps" % r
|
2008-03-07 04:16:38 +00:00
|
|
|
|
|
|
|
def abbreviate_size(data):
|
|
|
|
# 21.8kB, 554.4kB 4.37MB
|
|
|
|
if data is None:
|
|
|
|
return ""
|
|
|
|
r = float(data)
|
|
|
|
if r > 1000000000:
|
|
|
|
return "%1.2fGB" % (r/1000000000)
|
|
|
|
if r > 1000000:
|
|
|
|
return "%1.2fMB" % (r/1000000)
|
|
|
|
if r > 1000:
|
|
|
|
return "%.1fkB" % (r/1000)
|
2010-07-30 22:05:50 +00:00
|
|
|
return "%.0fB" % r
|
2008-05-19 19:57:04 +00:00
|
|
|
|
2009-03-04 02:40:19 +00:00
|
|
|
def plural(sequence_or_length):
|
|
|
|
if isinstance(sequence_or_length, int):
|
|
|
|
length = sequence_or_length
|
|
|
|
else:
|
|
|
|
length = len(sequence_or_length)
|
|
|
|
if length == 1:
|
|
|
|
return ""
|
|
|
|
return "s"
|
|
|
|
|
2008-05-19 19:57:04 +00:00
|
|
|
def text_plain(text, ctx):
|
|
|
|
req = IRequest(ctx)
|
|
|
|
req.setHeader("content-type", "text/plain")
|
|
|
|
req.setHeader("content-length", len(text))
|
|
|
|
return text
|
|
|
|
|
|
|
|
class WebError(Exception):
|
|
|
|
def __init__(self, text, code=http.BAD_REQUEST):
|
|
|
|
self.text = text
|
|
|
|
self.code = code
|
|
|
|
|
|
|
|
# XXX: to make UnsupportedMethod return 501 NOT_IMPLEMENTED instead of 500
|
|
|
|
# Internal Server Error, we either need to do that ICanHandleException trick,
|
|
|
|
# or make sure that childFactory returns a WebErrorResource (and never an
|
|
|
|
# actual exception). The latter is growing increasingly annoying.
|
|
|
|
|
|
|
|
def should_create_intermediate_directories(req):
|
|
|
|
t = get_arg(req, "t", "").strip()
|
|
|
|
return bool(req.method in ("PUT", "POST") and
|
|
|
|
t not in ("delete", "rename", "rename-form", "check"))
|
|
|
|
|
2009-03-07 11:54:08 +00:00
|
|
|
def humanize_failure(f):
|
|
|
|
# return text, responsecode
|
2009-12-27 20:10:43 +00:00
|
|
|
if f.check(EmptyPathnameComponentError):
|
|
|
|
return ("The webapi does not allow empty pathname components, "
|
|
|
|
"i.e. a double slash", http.BAD_REQUEST)
|
2009-03-07 11:54:08 +00:00
|
|
|
if f.check(ExistingChildError):
|
|
|
|
return ("There was already a child by that name, and you asked me "
|
|
|
|
"to not replace it.", http.CONFLICT)
|
|
|
|
if f.check(NoSuchChildError):
|
2011-01-22 01:40:06 +00:00
|
|
|
quoted_name = quote_output(f.value.args[0], encoding="utf-8", quotemarks=False)
|
|
|
|
return ("No such child: %s" % quoted_name, http.NOT_FOUND)
|
2009-03-07 11:54:08 +00:00
|
|
|
if f.check(NotEnoughSharesError):
|
2009-06-25 02:17:07 +00:00
|
|
|
t = ("NotEnoughSharesError: This indicates that some "
|
|
|
|
"servers were unavailable, or that shares have been "
|
|
|
|
"lost to server departure, hard drive failure, or disk "
|
|
|
|
"corruption. You should perform a filecheck on "
|
|
|
|
"this object to learn more.\n\nThe full error message is:\n"
|
|
|
|
"%s") % str(f.value)
|
|
|
|
return (t, http.GONE)
|
|
|
|
if f.check(NoSharesError):
|
|
|
|
t = ("NoSharesError: no shares could be found. "
|
|
|
|
"Zero shares usually indicates a corrupt URI, or that "
|
|
|
|
"no servers were connected, but it might also indicate "
|
|
|
|
"severe corruption. You should perform a filecheck on "
|
|
|
|
"this object to learn more.\n\nThe full error message is:\n"
|
|
|
|
"%s") % str(f.value)
|
2009-03-07 11:54:08 +00:00
|
|
|
return (t, http.GONE)
|
|
|
|
if f.check(UnrecoverableFileError):
|
|
|
|
t = ("UnrecoverableFileError: the directory (or mutable file) could "
|
|
|
|
"not be retrieved, because there were insufficient good shares. "
|
|
|
|
"This might indicate that no servers were connected, "
|
|
|
|
"insufficient servers were connected, the URI was corrupt, or "
|
|
|
|
"that shares have been lost due to server departure, hard drive "
|
|
|
|
"failure, or disk corruption. You should perform a filecheck on "
|
|
|
|
"this object to learn more.")
|
|
|
|
return (t, http.GONE)
|
2010-01-27 06:44:30 +00:00
|
|
|
if f.check(MustNotBeUnknownRWError):
|
2011-01-22 01:40:06 +00:00
|
|
|
quoted_name = quote_output(f.value.args[1], encoding="utf-8")
|
2010-01-27 06:44:30 +00:00
|
|
|
immutable = f.value.args[2]
|
|
|
|
if immutable:
|
|
|
|
t = ("MustNotBeUnknownRWError: an operation to add a child named "
|
2011-01-22 01:40:06 +00:00
|
|
|
"%s to a directory was given an unknown cap in a write slot.\n"
|
2010-01-27 06:44:30 +00:00
|
|
|
"If the cap is actually an immutable readcap, then using a "
|
|
|
|
"webapi server that supports a later version of Tahoe may help.\n\n"
|
|
|
|
"If you are using the webapi directly, then specifying an immutable "
|
|
|
|
"readcap in the read slot (ro_uri) of the JSON PROPDICT, and "
|
|
|
|
"omitting the write slot (rw_uri), would also work in this "
|
2011-01-22 01:40:06 +00:00
|
|
|
"case.") % quoted_name
|
2010-01-27 06:44:30 +00:00
|
|
|
else:
|
|
|
|
t = ("MustNotBeUnknownRWError: an operation to add a child named "
|
2011-01-22 01:40:06 +00:00
|
|
|
"%s to a directory was given an unknown cap in a write slot.\n"
|
2010-01-27 06:44:30 +00:00
|
|
|
"Using a webapi server that supports a later version of Tahoe "
|
|
|
|
"may help.\n\n"
|
|
|
|
"If you are using the webapi directly, specifying a readcap in "
|
|
|
|
"the read slot (ro_uri) of the JSON PROPDICT, as well as a "
|
|
|
|
"writecap in the write slot if desired, would also work in this "
|
2011-01-22 01:40:06 +00:00
|
|
|
"case.") % quoted_name
|
2010-01-27 06:44:30 +00:00
|
|
|
return (t, http.BAD_REQUEST)
|
|
|
|
if f.check(MustBeDeepImmutableError):
|
2011-01-22 01:40:06 +00:00
|
|
|
quoted_name = quote_output(f.value.args[1], encoding="utf-8")
|
2010-01-27 06:44:30 +00:00
|
|
|
t = ("MustBeDeepImmutableError: a cap passed to this operation for "
|
2011-01-22 01:40:06 +00:00
|
|
|
"the child named %s, needed to be immutable but was not. Either "
|
2010-01-27 06:44:30 +00:00
|
|
|
"the cap is being added to an immutable directory, or it was "
|
|
|
|
"originally retrieved from an immutable directory as an unknown "
|
2011-01-22 01:40:06 +00:00
|
|
|
"cap.") % quoted_name
|
2010-01-27 06:44:30 +00:00
|
|
|
return (t, http.BAD_REQUEST)
|
|
|
|
if f.check(MustBeReadonlyError):
|
2011-01-22 01:40:06 +00:00
|
|
|
quoted_name = quote_output(f.value.args[1], encoding="utf-8")
|
2010-01-27 06:44:30 +00:00
|
|
|
t = ("MustBeReadonlyError: a cap passed to this operation for "
|
|
|
|
"the child named '%s', needed to be read-only but was not. "
|
|
|
|
"The cap is being passed in a read slot (ro_uri), or was retrieved "
|
2011-01-22 01:40:06 +00:00
|
|
|
"from a read slot as an unknown cap.") % quoted_name
|
2009-11-18 07:09:00 +00:00
|
|
|
return (t, http.BAD_REQUEST)
|
2011-08-24 15:59:28 +00:00
|
|
|
if f.check(blacklist.FileProhibited):
|
|
|
|
t = "Access Prohibited: %s" % quote_output(f.value.reason, encoding="utf-8", quotemarks=False)
|
|
|
|
return (t, http.FORBIDDEN)
|
2009-03-07 11:54:08 +00:00
|
|
|
if f.check(WebError):
|
|
|
|
return (f.value.text, f.value.code)
|
|
|
|
if f.check(FileTooLargeError):
|
|
|
|
return (f.getTraceback(), http.REQUEST_ENTITY_TOO_LARGE)
|
|
|
|
return (str(f), None)
|
2008-05-19 19:57:04 +00:00
|
|
|
|
|
|
|
class MyExceptionHandler(appserver.DefaultExceptionHandler):
|
|
|
|
def simple(self, ctx, text, code=http.BAD_REQUEST):
|
|
|
|
req = IRequest(ctx)
|
|
|
|
req.setResponseCode(code)
|
2009-03-04 04:54:57 +00:00
|
|
|
#req.responseHeaders.setRawHeaders("content-encoding", [])
|
|
|
|
#req.responseHeaders.setRawHeaders("content-disposition", [])
|
2008-05-19 19:57:04 +00:00
|
|
|
req.setHeader("content-type", "text/plain;charset=utf-8")
|
|
|
|
if isinstance(text, unicode):
|
|
|
|
text = text.encode("utf-8")
|
2009-03-04 04:54:57 +00:00
|
|
|
req.setHeader("content-length", str(len(text)))
|
2008-05-19 19:57:04 +00:00
|
|
|
req.write(text)
|
2008-10-22 00:03:07 +00:00
|
|
|
# TODO: consider putting the requested URL here
|
2008-05-19 19:57:04 +00:00
|
|
|
req.finishRequest(False)
|
|
|
|
|
|
|
|
def renderHTTP_exception(self, ctx, f):
|
2009-06-25 02:17:07 +00:00
|
|
|
try:
|
|
|
|
text, code = humanize_failure(f)
|
|
|
|
except:
|
|
|
|
log.msg("exception in humanize_failure")
|
|
|
|
log.msg("argument was %s" % (f,))
|
|
|
|
log.err()
|
|
|
|
text, code = str(f), None
|
2009-03-07 11:54:08 +00:00
|
|
|
if code is not None:
|
|
|
|
return self.simple(ctx, text, code)
|
|
|
|
if f.check(server.UnsupportedMethod):
|
2008-05-19 19:57:04 +00:00
|
|
|
# twisted.web.server.Request.render() has support for transforming
|
|
|
|
# this into an appropriate 501 NOT_IMPLEMENTED or 405 NOT_ALLOWED
|
|
|
|
# return code, but nevow does not.
|
|
|
|
req = IRequest(ctx)
|
|
|
|
method = req.method
|
|
|
|
return self.simple(ctx,
|
|
|
|
"I don't know how to treat a %s request." % method,
|
|
|
|
http.NOT_IMPLEMENTED)
|
2009-03-04 04:54:57 +00:00
|
|
|
req = IRequest(ctx)
|
|
|
|
accept = req.getHeader("accept")
|
|
|
|
if not accept:
|
|
|
|
accept = "*/*"
|
|
|
|
if "*/*" in accept or "text/*" in accept or "text/html" in accept:
|
|
|
|
super = appserver.DefaultExceptionHandler
|
|
|
|
return super.renderHTTP_exception(self, ctx, f)
|
|
|
|
# use plain text
|
2009-03-07 11:54:08 +00:00
|
|
|
traceback = f.getTraceback()
|
2009-03-04 04:54:57 +00:00
|
|
|
return self.simple(ctx, traceback, http.INTERNAL_SERVER_ERROR)
|
2008-05-19 22:19:25 +00:00
|
|
|
|
2008-10-22 00:03:07 +00:00
|
|
|
class NeedOperationHandleError(WebError):
|
|
|
|
pass
|
|
|
|
|
2008-05-19 22:19:25 +00:00
|
|
|
class RenderMixin:
|
|
|
|
|
|
|
|
def renderHTTP(self, ctx):
|
|
|
|
request = IRequest(ctx)
|
|
|
|
|
|
|
|
# if we were using regular twisted.web Resources (and the regular
|
|
|
|
# twisted.web.server.Request object) then we could implement
|
|
|
|
# render_PUT and render_GET. But Nevow's request handler
|
|
|
|
# (NevowRequest.gotPageContext) goes directly to renderHTTP. Copy
|
|
|
|
# some code from the Resource.render method that Nevow bypasses, to
|
|
|
|
# do the same thing.
|
|
|
|
m = getattr(self, 'render_' + request.method, None)
|
|
|
|
if not m:
|
|
|
|
from twisted.web.server import UnsupportedMethod
|
|
|
|
raise UnsupportedMethod(getattr(self, 'allowedMethods', ()))
|
|
|
|
return m(ctx)
|