~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/controllers/download_ui.py

  • Committer: Michael Hudson
  • Date: 2009-03-16 06:23:00 UTC
  • Revision ID: michael.hudson@canonical.com-20090316062300-xzqamcrbksg4url4
fix minor visual issue caused by IE compatibility work

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
import logging
21
21
import mimetypes
 
22
import time
22
23
import urllib
23
24
 
24
25
from paste import httpexceptions
33
34
 
34
35
    def __call__(self, environ, start_response):
35
36
        # /download/<rev_id>/<file_id>/[filename]
 
37
        z = time.time()
36
38
 
37
39
        h = self._history
38
40
 
39
41
        args = []
40
 
        while True:
 
42
        while 1:
41
43
            arg = path_info_pop(environ)
42
44
            if arg is None:
43
45
                break
44
46
            args.append(arg)
45
47
 
46
48
        if len(args) < 2:
47
 
            raise httpexceptions.HTTPMovedPermanently(
48
 
                self._branch.absolute_url('/changes'))
 
49
            raise httpexceptions.HTTPMovedPermanently(self._branch.url(
 
50
                      '../changes'))
49
51
 
50
52
        revid = h.fix_revid(args[0])
51
53
        file_id = args[1]
61
63
        encoded_filename = urllib.quote(filename.encode('utf-8'))
62
64
        headers = [
63
65
            ('Content-Type', mime_type),
64
 
            ('Content-Length', str(len(content))),
 
66
            ('Content-Length', len(content)),
65
67
            ('Content-Disposition',
66
 
             "attachment; filename*=utf-8''%s" % (encoded_filename,)),
 
68
             'attachment; filename*=utf-8\'\'%s' % encoded_filename),
67
69
            ]
68
70
        start_response('200 OK', headers)
69
71
        return [content]