42
42
# response body may contain the requested file.
44
44
# Fileservice has two separate roles: First, an action is performed. This may
45
# be a copy, write, or svn up operation. Then, a file or directory listing is
46
# returned. This directory listing may be completely separate from the action,
45
# be a copy, write, or svn up operation. Then, either a directory listing or
46
# file contents are returned.
47
# This listing/contents may be completely separate from the action,
47
48
# but they are performed together because the client will usually want to
48
49
# perform some action, then update its display as a result of the action.
50
# GET requests will have all variables ignored, and the only behaviour will be
51
# to generate the directory or file listing. POST requests will result in an
52
# action if one is specified. If the action is UNSUCCESSFUL, returns the
53
# header "X-IVLE-Action-Error: <errormessage>". Successful actions succeed
54
# silently. Note that the action does not affect the HTTP response code (it
55
# may be 200 even upon failure).
51
# The special "return" variable can be "listing" or "contents" - listing is
52
# the default if unspecified. If "listing", it will return a directory listing
53
# of the file specified. If the file is not a directory, it just returns a
54
# single "." object, with details about the file.
55
# If "contents", it will return the contents of the file specified. If the
56
# file is a directory, it will simply return the listing again.
58
# GET requests will have all variables other than "return" ignored, and the
59
# only behaviour will be to generate the directory or file listing. POST
60
# requests will result in an action if one is specified. If the action is
61
# UNSUCCESSFUL, returns the header "X-IVLE-Action-Error: <errormessage>".
62
# Successful actions succeed silently. Note that the action does not affect
63
# the HTTP response code (it may be 200 even upon failure).
57
65
# The path (req.path) controls which file or directory will be
58
66
# returned. If it is a file, returns the header "X-IVLE-Return: File" and
59
# status 200 OK. The response body is a verbatim dump of the file specified.
67
# status 200 OK. The response body is either a verbatim dump of the file
68
# specified, or a single-file directory listing, as described above.
60
69
# The Content-Type will probably be text/plain but should not be relied upon.
61
70
# If it is a directory, returns the header "X-IVLE-Return: Dir" and status
62
71
# 200 OK. The response body is a JSON directory listing (see below). The
113
121
except action.ActionError, message:
114
122
req.headers_out['X-IVLE-Action-Error'] = str(message)
116
listing.handle_return(req)
124
return_type = fields.getfirst('return')
125
# TEMP: Assume return=contents by default.
126
# (In the final, it will be "listing" by default; this is for backwards
128
if return_type is None:
129
return_type = "contents"
131
listing.handle_return(req, return_type == "contents")