~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to lib/fileservice_lib/__init__.py

  • Committer: mattgiuca
  • Date: 2008-02-28 04:35:09 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:601
fileservice_lib: Added to fileservice a new query argument "return".
    If "contents", then this will behave as it always did.
    If "listing", then it will return a dir listing, even if it is not a
        directory. This will be used to get info about a file before getting
        its contents.
    For now, "contents" is the default to be backwards compatible with the
    client, but "listing" will be the default.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
# response body may contain the requested file.
43
43
 
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.
49
50
 
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.
 
57
 
 
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).
56
64
 
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
102
111
    # Ignore arguments if not POST, since we aren't allowed to cause
103
112
    # side-effects on the server.
104
113
    act = None
105
 
    fields = None
 
114
    fields = req.get_fieldstorage()
106
115
    if req.method == 'POST':
107
 
        fields = req.get_fieldstorage()
108
116
        act = fields.getfirst('action')
109
117
    
110
118
    if act is not None:
113
121
        except action.ActionError, message:
114
122
            req.headers_out['X-IVLE-Action-Error'] = str(message)
115
123
 
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
 
127
    # compatibility).
 
128
    if return_type is None:
 
129
        return_type = "contents"
 
130
    # END TEMP
 
131
    listing.handle_return(req, return_type == "contents")