~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/controllers/download_ui.py

  • Committer: Robey Pointer
  • Date: 2007-03-26 06:21:06 UTC
  • Revision ID: robey@lag.net-20070326062106-1fehbvag3z2o2q0f
(bug 86247)
it's possible for a commit to have no message at all.  in that case, don't
try to index into it. :)

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 
37
37
class DownloadUI (object):
38
38
 
 
39
    def __init__(self, branch):
 
40
        # BranchView object
 
41
        self._branch = branch
 
42
        self.log = branch.log
 
43
 
39
44
    @turbogears.expose()
40
45
    def default(self, *args, **kw):
41
46
        # /download/<rev_id>/<file_id>/[filename]
42
47
        z = time.time()
43
 
        h = util.get_history()
 
48
        h = self._branch.get_history()
44
49
        
45
50
        if len(args) < 2:
46
 
            raise HTTPRedirect(turbogears.url('/changes'))
 
51
            raise HTTPRedirect(self._branch.url('/changes'))
47
52
        
48
53
        revid = h.fix_revid(args[0])
49
54
        file_id = args[1]
50
 
        filename, content = h.get_file(file_id, revid)
 
55
        path, filename, content = h.get_file(file_id, revid)
51
56
        mime_type, encoding = mimetypes.guess_type(filename)
52
57
        if mime_type is None:
53
58
            mime_type = 'application/octet-stream'
54
 
        
 
59
 
 
60
        self.log.info('/download %s @ %s (%d bytes)', path, h.get_revno(revid), len(content))
55
61
        response.headers['Content-Type'] = mime_type
56
62
        response.headers['Content-Length'] = len(content)
57
63
        response.body = content