Skip to content


Root download #104

merged 3 commits into from

2 participants

the rootpy project member

see #103

the rootpy project member

FileResponse seems to be the right respose to use. I get "The resource could not be found." I don't think the path is a problem, I have tried to use something like /home/ruggero/aaa.txt instead of self.path

the rootpy project member

same result here: "The resource could not be found."

@pwaller pwaller merged commit a9a7042 into rootpy:master
@wiso wiso deleted the wiso:ROOTdownload branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 28, 2013
  1. @wiso

    start to implement download action

    wiso committed
Commits on Mar 29, 2013
  1. @wiso
  2. @wiso

    fix chrome

    wiso committed
This page is out of date. Refresh to see the latest.
Showing with 21 additions and 3 deletions.
  1. +21 −3 weboot/resources/
24 weboot/resources/
@@ -1,7 +1,7 @@
from .. import log; log = log[__name__]
from os import listdir
-from os.path import basename, exists, isfile, isdir, join as pjoin
+from os.path import basename, abspath, exists, isfile, isdir, join as pjoin
import fnmatch
import re
@@ -9,9 +9,12 @@
from pyramid.traversal import traverse
from pyramid.url import static_url
from pyramid.httpexceptions import HTTPNotFound
+from pyramid.response import FileResponse
import ROOT as R
+from .renderable import Renderer
+from .actions import action
from .locationaware import LocationAware
from .multitraverser import MultipleTraverser
from ._markdown import MarkdownResource
@@ -19,6 +22,17 @@
from ..utils.root_vfs import RootVFS
from .root.builder import build_root_object
+class Downloader(Renderer):
+ @property
+ def content(self):
+ filename = abspath(self.format)
+ response = FileResponse(filename)
+ response.headers['Content-type'] = 'application/octet-stream'
+ response.headers['Content-Disposition'] = 'attachment; filename="{0}";'.format(basename(filename))
+ return response
class VFSTraverser(LocationAware):
section = "directory"
@@ -26,11 +40,15 @@ def __init__(self, request, path=None, vfs=None):
self.request = request
self.path = path or request.registry.settings["results_path"]
self.vfs = vfs or RootVFS(self.path)
+ @action
+ def download(self, parent, key):
+ return Downloader.from_parent(parent, key, self, self.path)
def name(self):
return basename(self.path)
def icon_url(self):
p = self.vfs.get(self.path)
Something went wrong with that request. Please try again.