state (it may leave some intermediate directory nodes).
GET FILEURL?t=json
- GET FILEURL?t=xml
This returns machine-parseable information about the file in the HTTP
response body, including file size, metadata (like Content-Type), and URIs.
do their job.
GET DIRURL?t=json
- GET DIRURL?t=xml
This returns machine-parseable information about this directory in the HTTP
response body. This information first contains a flag to indicate that
dirnode. Finally it also contains information about the children of this
directory, probably as a mapping from child name to a set of metadata about
the child (basically the same data that would appear in a corresponding
- GET?t=xml of the child itself). A programmatic client should be able to use
+ GET?t=json of the child itself). A programmatic client should be able to use
the information from this query to display filesystem navigation choices to
a human user.
uri_link = urllib.quote(target.get_uri().replace("/", "!"))
childdata = [T.a(href="%s?t=json" % name)["JSON"], ", ",
- T.a(href="%s?t=xml" % name)["XML"], ", ",
T.a(href="%s?t=uri" % name)["URI"], ", ",
T.a(href="%s?t=readonly-uri" % name)["readonly-URI"], ", ",
T.a(href="/uri/%s" % uri_link)["URI-link"],
def finish(self):
pass
-class TypedFile(static.File):
- # serve data from a named file, but using a Content-Type derived from a
- # different filename
- isLeaf = True
- def __init__(self, path, requested_filename):
- static.File.__init__(self, path)
- gte = static.getTypeAndEncoding
- self.type, self.encoding = gte(requested_filename,
- self.contentTypes,
- self.contentEncodings,
- self.defaultType)
-
class FileDownloader(resource.Resource):
def __init__(self, filenode, name):
IFileNode(filenode)
data += "uri=%s, size=%s" % (file_uri, pieces['size'])
return data
-class FileXMLMetadata(FileJSONMetadata):
- def renderNode(self, filenode):
- file_uri = filenode.get_uri()
- pieces = unpack_uri(file_uri)
- data = "<xmlish>\n"
- data += "filenode\n"
- data += "stuff here\n"
- data += "uri=%s, size=%s" % (file_uri, pieces['size'])
- return data
-
class FileURI(FileJSONMetadata):
def renderNode(self, filenode):
file_uri = filenode.get_uri()
d.addCallback(_done)
return d
-class DirectoryXMLMetadata(DirectoryJSONMetadata):
- def renderNode(self, node):
- data = "<xmlish>\n"
- data += "dirnode\n"
- data += "stuff here\n"
- d = node.list()
- def _got(children, data):
- for name, childnode in children.iteritems():
- data += "name=%s, child_uri=%s" % (name, childnode.get_uri())
- return data
- d.addCallback(_got, data)
- def _done(data):
- data += "</done>\n"
- return data
- d.addCallback(_done)
- return d
-
class DirectoryURI(DirectoryJSONMetadata):
def renderNode(self, node):
return node.get_uri()
return FileDownloader(node, filename), ()
elif t == "json":
return FileJSONMetadata(node), ()
- elif t == "xml":
- return FileXMLMetadata(node), ()
elif t == "uri":
return FileURI(node), ()
elif t == "readonly-uri":
return Directory(self.name, node, path), ()
elif t == "json":
return DirectoryJSONMetadata(node), ()
- elif t == "xml":
- return DirectoryXMLMetadata(node), ()
elif t == "uri":
return DirectoryURI(node), ()
elif t == "readonly-uri":