~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/controllers/download_ui.py

  • Committer: Martin Albisetti
  • Date: 2008-06-16 08:49:28 UTC
  • mto: (159.1.1 remove_caches)
  • mto: This revision was merged to the branch mainline in revision 160.
  • Revision ID: argentina@gmail.com-20080616084928-bycmp69jhmqmt9vi
 * Remove fulltext cache
 * Remove revisions cache

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import mimetypes
22
22
import time
23
23
 
24
 
from paste import httpexceptions
25
 
from paste.request import path_info_pop
 
24
import turbogears
 
25
from cherrypy import HTTPRedirect, response
 
26
 
26
27
 
27
28
log = logging.getLogger("loggerhead.controllers")
28
29
 
34
35
        self._branch = branch
35
36
        self.log = branch.log
36
37
 
37
 
    def default(self, request, response):
 
38
    @turbogears.expose()
 
39
    def default(self, *args, **kw):
38
40
        # /download/<rev_id>/<file_id>/[filename]
39
41
        z = time.time()
40
 
        h = self._branch.history
41
 
 
 
42
        h = self._branch.get_history()
 
43
        
42
44
        h._branch.lock_read()
43
45
        try:
44
 
            args = []
45
 
            while 1:
46
 
                arg = path_info_pop(request.environ)
47
 
                if arg is None:
48
 
                    break
49
 
                args.append(arg)
50
 
 
51
46
            if len(args) < 2:
52
 
                raise httpexceptions.HTTPMovedPermanently(self._branch.url('../changes'))
 
47
                raise HTTPRedirect(self._branch.url('/changes'))
53
48
 
54
49
            revid = h.fix_revid(args[0])
55
50
            file_id = args[1]
62
57
            response.headers['Content-Type'] = mime_type
63
58
            response.headers['Content-Length'] = len(content)
64
59
            response.headers['Content-Disposition'] = 'attachment; filename=%s'%(filename,)
65
 
            response.write(content)
 
60
            response.body = content
 
61
            return response.body
66
62
        finally:
67
63
            h._branch.unlock()