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

« back to all changes in this revision

Viewing changes to lib/fileservice_lib/listing.py

  • Committer: wagrant
  • Date: 2008-07-17 04:08:43 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:904
fileservice_lib: Factor revision URL checking out of get_dirlisting.

Show diffs side-by-side

added added

removed removed

Lines of Context:
176
176
        req.headers_out['X-IVLE-Return'] = 'File'
177
177
        req.write(cjson.encode(get_dirlisting(req, svnclient, path)))
178
178
 
179
 
def get_dirlisting(req, svnclient, path):
180
 
    """Given a local absolute path, creates a directory listing object
181
 
    ready to be JSONized and sent to the client.
182
 
 
183
 
    req: Request object. Will not be mutated; just reads the session.
184
 
    svnclient: Svn client object.
185
 
    path: String. Absolute path on the local file system. Not checked,
186
 
        must already be guaranteed safe. May be a file or a directory.
187
 
    """
188
 
    # Are we in 'revision mode' - has someone sent the 'r' query
 
179
def _get_revision_or_die(req, svnclient, path):
 
180
    '''Looks for a revision specification in req's URL, returning the revision
 
181
       specified. Returns None if there was no revision specified. Errors and
 
182
       terminates the request if the specification was bad, or it doesn't exist
 
183
       for the given path.
 
184
    '''
189
185
    # Work out the revisions from query
190
186
    r_str = req.get_fieldstorage().getfirst("r")
191
187
    revision = common.svn.revision_from_string(r_str)
199
195
        req.write('Revision not found')
200
196
        req.flush()
201
197
        sys.exit()
 
198
    return revision
 
199
 
 
200
 
 
201
def get_dirlisting(req, svnclient, path):
 
202
    """Given a local absolute path, creates a directory listing object
 
203
    ready to be JSONized and sent to the client.
 
204
 
 
205
    req: Request object. Will not be mutated; just reads the session.
 
206
    svnclient: Svn client object.
 
207
    path: String. Absolute path on the local file system. Not checked,
 
208
        must already be guaranteed safe. May be a file or a directory.
 
209
    """
 
210
 
 
211
    revision = _get_revision_or_die(req, svnclient, path)
202
212
 
203
213
    # Start by trying to do an SVN status, so we can report file version
204
214
    # status