self.failUnlessEqual(self._mutable_uri, newnode.get_uri())
d.addCallback(_got3)
+ # look at the JSON form of the enclosing directory
d.addCallback(lambda res:
self.GET(self.public_url + "/foo/?t=json",
followRedirect=True))
self.failUnlessEqual(new_json[1]["ro_uri"], ro_uri)
d.addCallback(_check_page_json)
+ # and the JSON form of the file
+ d.addCallback(lambda res:
+ self.GET(self.public_url + "/foo/new.txt?t=json"))
+ def _check_file_json(res):
+ parsed = simplejson.loads(res)
+ self.failUnlessEqual(parsed[0], "filenode")
+ 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)
+ d.addCallback(_check_file_json)
+
# and look at t=uri and t=readonly-uri
d.addCallback(lambda res:
self.GET(self.public_url + "/foo/new.txt?t=uri"))
return server.NOT_DONE_YET
def FileJSONMetadata(ctx, filenode):
- file_uri = filenode.get_uri()
- data = ("filenode",
- {'ro_uri': file_uri,
- 'size': filenode.get_size(),
- })
+ if filenode.is_readonly():
+ rw_uri = None
+ ro_uri = filenode.get_uri()
+ else:
+ rw_uri = filenode.get_uri()
+ ro_uri = filenode.get_readonly_uri()
+ data = ("filenode", {})
+ data[1]['size'] = filenode.get_size()
+ if ro_uri:
+ data[1]['ro_uri'] = ro_uri
+ if rw_uri:
+ data[1]['rw_uri'] = rw_uri
return text_plain(simplejson.dumps(data, indent=1), ctx)
def FileURI(ctx, filenode):