]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blobdiff - src/allmydata/web/common.py
Change web-API to support t=relink instead of t=move (+ docs and tests). fixes #1732
[tahoe-lafs/tahoe-lafs.git] / src / allmydata / web / common.py
index 9bfed072c8a70bb96a50b6818fdf9ea566aeb392..c3b94d2a36957c238a1355a5332096231f968e8e 100644 (file)
@@ -24,14 +24,17 @@ def getxmlfile(name):
 
 def boolean_of_arg(arg):
     # TODO: ""
-    assert arg.lower() in ("true", "t", "1", "false", "f", "0", "on", "off")
+    if arg.lower() not in ("true", "t", "1", "false", "f", "0", "on", "off"):
+        raise WebError("invalid boolean argument: %r" % (arg,), http.BAD_REQUEST)
     return arg.lower() in ("true", "t", "1", "on")
 
 def parse_replace_arg(replace):
     if replace.lower() == "only-files":
         return replace
-    else:
+    try:
         return boolean_of_arg(replace)
+    except WebError:
+        raise WebError("invalid replace= argument: %r" % (replace,), http.BAD_REQUEST)
 
 
 def get_format(req, default="CHK"):
@@ -56,6 +59,11 @@ def get_mutable_type(file_format): # accepts result of get_format()
     elif file_format == "MDMF":
         return MDMF_VERSION
     else:
+        # 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()
         return None