From: Brian Warner Date: Tue, 20 May 2008 22:40:49 +0000 (-0700) Subject: web t=json: add 'mutable' key to the information dict X-Git-Tag: allmydata-tahoe-1.1.0~91 X-Git-Url: https://git.rkrishnan.org/components/index.php?a=commitdiff_plain;h=3ac4a734e507abbf240f3766cc3a15e7d2813249;p=tahoe-lafs%2Ftahoe-lafs.git web t=json: add 'mutable' key to the information dict --- diff --git a/docs/webapi.txt b/docs/webapi.txt index e5cd611e..7dff96fa 100644 --- a/docs/webapi.txt +++ b/docs/webapi.txt @@ -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, diff --git a/src/allmydata/test/test_web.py b/src/allmydata/test/test_web.py index 2df1cdd7..90a7be0d 100644 --- a/src/allmydata/test/test_web.py +++ b/src/allmydata/test/test_web.py @@ -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) diff --git a/src/allmydata/web/directory.py b/src/allmydata/web/directory.py index 55dec9c7..7a3473d9 100644 --- a/src/allmydata/web/directory.py +++ b/src/allmydata/web/directory.py @@ -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) diff --git a/src/allmydata/web/filenode.py b/src/allmydata/web/filenode.py index f65af29e..19b1b47e 100644 --- a/src/allmydata/web/filenode.py +++ b/src/allmydata/web/filenode.py @@ -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):