~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/controllers/download_ui.py

  • Committer: Robey Pointer
  • Date: 2006-12-20 22:17:33 UTC
  • Revision ID: robey@lag.net-20061220221733-1y0ix5n2eexmltdo
update README

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
        z = time.time()
48
48
        h = self._branch.get_history()
49
49
        
50
 
        h._branch.lock_read()
51
 
        try:
52
 
            if len(args) < 2:
53
 
                raise HTTPRedirect(self._branch.url('/changes'))
54
 
 
55
 
            revid = h.fix_revid(args[0])
56
 
            file_id = args[1]
57
 
            path, filename, content = h.get_file(file_id, revid)
58
 
            mime_type, encoding = mimetypes.guess_type(filename)
59
 
            if mime_type is None:
60
 
                mime_type = 'application/octet-stream'
61
 
 
62
 
            self.log.info('/download %s @ %s (%d bytes)', path, h.get_revno(revid), len(content))
63
 
            response.headers['Content-Type'] = mime_type
64
 
            response.headers['Content-Length'] = len(content)
65
 
            response.headers['Content-Disposition'] = 'attachment; filename=%s'%(filename,)
66
 
            response.body = content
67
 
            return response.body
68
 
        finally:
69
 
            h._branch.unlock()
 
50
        if len(args) < 2:
 
51
            raise HTTPRedirect(self._branch.url('/changes'))
 
52
        
 
53
        revid = h.fix_revid(args[0])
 
54
        file_id = args[1]
 
55
        filename, content = h.get_file(file_id, revid)
 
56
        mime_type, encoding = mimetypes.guess_type(filename)
 
57
        if mime_type is None:
 
58
            mime_type = 'application/octet-stream'
 
59
        
 
60
        response.headers['Content-Type'] = mime_type
 
61
        response.headers['Content-Length'] = len(content)
 
62
        response.body = content
 
63
        return response.body