]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
webish: modify JSON to match zooko's proposed API changes in #118
authorBrian Warner <warner@allmydata.com>
Thu, 23 Aug 2007 20:00:39 +0000 (13:00 -0700)
committerBrian Warner <warner@allmydata.com>
Thu, 23 Aug 2007 20:00:39 +0000 (13:00 -0700)
src/allmydata/test/test_web.py
src/allmydata/webish.py

index 6587d74ae5d5220df8473fdfa37d74043c9d055e..e2356a495bd861983941cda0e6945e38bc791baa 100644 (file)
@@ -268,17 +268,18 @@ class WebMixin(object):
         self.failUnless(isinstance(data, list))
         self.failUnlessEqual(data[0], "filenode")
         self.failUnless(isinstance(data[1], dict))
-        self.failUnlessEqual(data[1]["mutable"], False)
+        self.failIf("rw_uri" in data[1]) # immutable
+        self.failUnlessEqual(data[1]["ro_uri"], self._bar_txt_uri)
         self.failUnlessEqual(data[1]["size"], 123)
-        self.failUnlessEqual(data[1]["uri"], self._bar_txt_uri)
 
     def failUnlessIsFooJSON(self, res):
         data = self.worlds_cheapest_json_decoder(res)
         self.failUnless(isinstance(data, list))
         self.failUnlessEqual(data[0], "dirnode")
         self.failUnless(isinstance(data[1], dict))
-        self.failUnlessEqual(data[1]["mutable"], True)
-        self.failUnlessEqual(data[1]["uri"], self._foo_uri)
+        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)
         kidnames = sorted(data[1]["children"].keys())
         self.failUnlessEqual(kidnames,
                              ["bar.txt", "blockingfile", "empty", "sub"])
@@ -286,7 +287,7 @@ class WebMixin(object):
         self.failUnlessEqual(kids["sub"][0], "dirnode")
         self.failUnlessEqual(kids["bar.txt"][0], "filenode")
         self.failUnlessEqual(kids["bar.txt"][1]["size"], 123)
-        self.failUnlessEqual(kids["bar.txt"][1]["uri"], self._bar_txt_uri)
+        self.failUnlessEqual(kids["bar.txt"][1]["ro_uri"], self._bar_txt_uri)
 
     def GET(self, urlpath, followRedirect=False):
         url = self.webish_url + urlpath
index 52c5ffe3b2c5e1d93bd4d2138e4c64b4c4bcaf27..7f030e81f22ed0bac3a9852568cc0365800d04d9 100644 (file)
@@ -398,8 +398,7 @@ class FileJSONMetadata(rend.Page):
     def renderNode(self, filenode):
         file_uri = filenode.get_uri()
         data = ("filenode",
-                {'mutable': False,
-                 'uri': file_uri,
+                {'ro_uri': file_uri,
                  'size': filenode.get_size(),
                  })
         return simplejson.dumps(data, indent=1)
@@ -488,22 +487,22 @@ class DirectoryJSONMetadata(rend.Page):
                 if IFileNode.providedBy(childnode):
                     kiduri = childnode.get_uri()
                     kiddata = ("filenode",
-                               {'mutable': False,
-                                'uri': kiduri,
+                               {'ro_uri': kiduri,
                                 'size': childnode.get_size(),
                                 })
                 else:
                     assert IDirectoryNode.providedBy(childnode)
-                    kiduri = childnode.get_uri()
                     kiddata = ("dirnode",
-                               {'mutable': childnode.is_mutable(),
-                                'uri': kiduri,
+                               {'ro_uri': childnode.get_immutable_uri(),
                                 })
+                    if childnode.is_mutable():
+                        kiddata[1]['rw_uri'] = childnode.get_uri()
                 kids[name] = kiddata
             contents = { 'children': kids,
-                         'mutable': node.is_mutable(),
-                         'uri': node.get_uri(),
+                         'ro_uri': node.get_immutable_uri(),
                          }
+            if node.is_mutable():
+                contents['rw_uri'] = node.get_uri()
             data = ("dirnode", contents)
             return simplejson.dumps(data, indent=1)
         d.addCallback(_got)