Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Download ROOT file #103

Closed
wiso opened this Issue · 7 comments

2 participants

@wiso
Collaborator

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

@pwaller
Owner

That looks pretty close. What happens?

@wiso
Collaborator

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

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

@pwaller
Owner

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.

@wiso
Collaborator

ok, thank you for the explaination. I think I have fixed here: wiso@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

@wiso
Collaborator

ok, maybe I have fixed: wiso@1c58831

@pwaller
Owner

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

@wiso wiso referenced this issue
Merged

Root download #104

@wiso
Collaborator
@pwaller pwaller closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.