Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Download ROOT file #103

Closed
wiso opened this Issue Mar 28, 2013 · 7 comments

Comments

Projects
None yet
2 participants
Member

wiso commented Mar 28, 2013

Hello, it would be nice to add the possibility to download a ROOT file. I am trying to do it [1], but I am not so skilled with pyramid libraries...

[1] https://github.com/wiso/WebOOT/commits/ROOTdownload

Owner

pwaller commented Mar 28, 2013

That looks pretty close. What happens?

Member

wiso commented Mar 28, 2013

I have added some comments in the commit: wiso/WebOOT@f2b6159

essentially I get: "The resource could not be found."

Owner

pwaller commented Mar 28, 2013

Conceptually, there are two things to worry about.

First one is the Resource. That's a Root Object, etc. The second thing is the view.

Traversal (the object[a][b][c] thing) results in a Resource. This resource becomes the context for the view.

Given a resource, a view generates a response which gets sent to the browser. The return value of an action should be a resource, not a response.

The mapping of contexts (resources) onto views happens in the weboot/init.py.

So for example, from the link I linked to, objects implementing Renderable get rendered by the renderable.renderer_view.

This just calls renderable.content. For !archive/beamer that results in whatever response is returned by the ArchiveBuilder.beamer property.

Does that help a little? The main thing is that you need to return a Resource from your !download action, and that resource should then have a way of being rendered. If it inherits from Renderer, then it just has to implement the content property, which can return a Response.

Another shortcut to all of this could be to just add a new view to __init__.py when the context is a Response object. This view could just return the context itself, and then your code would work as is.

Member

wiso commented Mar 29, 2013

ok, thank you for the explaination. I think I have fixed here: wiso/WebOOT@f0d1ec2

on firefox it works properly, with chrome it saves a file called "!download". Any ideas?

I think I am following this: http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1

Member

wiso commented Mar 29, 2013

ok, maybe I have fixed: wiso/WebOOT@1c58831

Owner

pwaller commented Mar 29, 2013

looks fine to me. Want to send a pull request?

@wiso wiso referenced this issue Mar 29, 2013

Merged

Root download #104

Member

wiso commented Mar 29, 2013

done. Ruggero

2013/3/29 Peter Waller notifications@github.com

looks fine to me. Want to send a pull request?


Reply to this email directly or view it on GitHubhttps://github.com/rootpy/WebOOT/issues/103#issuecomment-15638150
.

@pwaller pwaller closed this Mar 30, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment