]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
web t=json: add 'mutable' key to the information dict
authorBrian Warner <warner@allmydata.com>
Tue, 20 May 2008 22:40:49 +0000 (15:40 -0700)
committerBrian Warner <warner@allmydata.com>
Tue, 20 May 2008 22:40:49 +0000 (15:40 -0700)
docs/webapi.txt
src/allmydata/test/test_web.py
src/allmydata/web/directory.py
src/allmydata/web/filenode.py

index e5cd611e8f7eead86d950037a623c4410b60cfd7..7dff96fa883e3be4971172f7285a35d40eef4cc9 100644 (file)
@@ -298,6 +298,7 @@ GET /uri/$DIRCAP/[SUBDIRS../]FILENAME?t=json
 
     [ "filenode", { "ro_uri": file_uri,
                     "size": bytes,
+                    "mutable": false,
                     "metadata": {"ctime": 1202777696.7564139,
                                  "mtime": 1202777696.7564139
                                  }
@@ -315,6 +316,7 @@ GET /uri/$DIRCAP/[SUBDIRS../]FILENAME?t=json
 
     [ "dirnode", { "rw_uri": read_write_uri,
                    "ro_uri": read_only_uri,
+                   "mutable": true,
                    "children": {
                      "foo.txt": [ "filenode", { "ro_uri": uri,
                                                 "size": bytes,
index 2df1cdd7af793f0755c69ca5618343fb3cf3a939..90a7be0de3019529e58b949aa000686d5851fc85 100644 (file)
@@ -183,6 +183,7 @@ class WebMixin(object):
         self.failUnless(isinstance(data, list))
         self.failUnlessEqual(data[0], "filenode")
         self.failUnless(isinstance(data[1], dict))
+        self.failIf(data[1]["mutable"])
         self.failIf("rw_uri" in data[1]) # immutable
         self.failUnlessEqual(data[1]["ro_uri"], self._bar_txt_uri)
         self.failUnlessEqual(data[1]["size"], len(self.BAR_CONTENTS))
@@ -192,6 +193,7 @@ class WebMixin(object):
         self.failUnless(isinstance(data, list))
         self.failUnlessEqual(data[0], "dirnode", res)
         self.failUnless(isinstance(data[1], dict))
+        self.failUnless(data[1]["mutable"])
         self.failUnless("rw_uri" in data[1]) # mutable
         self.failUnlessEqual(data[1]["rw_uri"], self._foo_uri)
         self.failUnlessEqual(data[1]["ro_uri"], self._foo_readonly_uri)
@@ -1150,6 +1152,7 @@ class Web(WebMixin, unittest.TestCase):
             self.failUnless("new.txt" in children)
             new_json = children["new.txt"]
             self.failUnlessEqual(new_json[0], "filenode")
+            self.failUnless(new_json[1]["mutable"])
             self.failUnlessEqual(new_json[1]["rw_uri"], self._mutable_uri)
             ro_uri = unicode(self._mutable_node.get_readonly().to_string())
             self.failUnlessEqual(new_json[1]["ro_uri"], ro_uri)
@@ -1161,6 +1164,7 @@ class Web(WebMixin, unittest.TestCase):
         def _check_file_json(res):
             parsed = simplejson.loads(res)
             self.failUnlessEqual(parsed[0], "filenode")
+            self.failUnless(parsed[1]["mutable"])
             self.failUnlessEqual(parsed[1]["rw_uri"], self._mutable_uri)
             ro_uri = unicode(self._mutable_node.get_readonly().to_string())
             self.failUnlessEqual(parsed[1]["ro_uri"], ro_uri)
index 55dec9c7926db8c1dea313264ed3045c9ac80a8d..7a3473d9cfeed096f4fae3d8283486b2fd668ae4 100644 (file)
@@ -645,6 +645,7 @@ def DirectoryJSONMetadata(ctx, dirnode):
                 kiddata[1]["ro_uri"] = ro_uri
             if rw_uri:
                 kiddata[1]["rw_uri"] = rw_uri
+            kiddata[1]['mutable'] = childnode.is_mutable()
             kids[name] = kiddata
         if dirnode.is_readonly():
             drw_uri = None
@@ -657,6 +658,7 @@ def DirectoryJSONMetadata(ctx, dirnode):
             contents['ro_uri'] = dro_uri
         if drw_uri:
             contents['rw_uri'] = drw_uri
+        contents['mutable'] = dirnode.is_mutable()
         data = ("dirnode", contents)
         return simplejson.dumps(data, indent=1)
     d.addCallback(_got)
index f65af29e67939f94766067db5b44ca90f963d007..19b1b47e1e105e656a0663151c6aa520fa704720 100644 (file)
@@ -380,6 +380,7 @@ def FileJSONMetadata(ctx, filenode):
         data[1]['ro_uri'] = ro_uri
     if rw_uri:
         data[1]['rw_uri'] = rw_uri
+    data[1]['mutable'] = filenode.is_mutable()
     return text_plain(simplejson.dumps(data, indent=1), ctx)
 
 def FileURI(ctx, filenode):