~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-01 17:47:52 UTC
  • mfrom: (283.1.1 bug-329668)
  • Revision ID: michael.hudson@canonical.com-20090301174752-vpp55v8c3fwyjwmc
fix bug #329668 ("Inventory page uses "//" in links")

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import logging
21
21
import mimetypes
22
22
import time
 
23
import urllib
23
24
 
24
25
from paste import httpexceptions
25
26
from paste.request import path_info_pop
26
27
 
 
28
from loggerhead.controllers import TemplatedBranchView
 
29
 
27
30
log = logging.getLogger("loggerhead.controllers")
28
31
 
29
32
 
30
 
class DownloadUI (object):
31
 
 
32
 
    def __init__(self, branch, history):
33
 
        self._branch = branch
34
 
        self._history = history
35
 
        self.log = branch.log
 
33
class DownloadUI (TemplatedBranchView):
36
34
 
37
35
    def __call__(self, environ, start_response):
38
36
        # /download/<rev_id>/<file_id>/[filename]
62
60
                      path,
63
61
                      h.get_revno(revid),
64
62
                      len(content))
 
63
        encoded_filename = urllib.quote(filename.encode('utf-8'))
65
64
        headers = [
66
65
            ('Content-Type', mime_type),
67
66
            ('Content-Length', len(content)),
68
 
            ('Content-Disposition', 'attachment; filename=%s' % filename),
 
67
            ('Content-Disposition',
 
68
             'attachment; filename*=utf-8\'\'%s' % encoded_filename),
69
69
            ]
70
70
        start_response('200 OK', headers)
71
71
        return [content]