@render.download
not namespacing properly, used to work in deprecated @session.download
#1724
Labels
bug
Something isn't working
Hi all,
I faced an issue in one of our applications, where when using
@render.download
the generated URLs are not properly namespaced (actually the download URL appears to be living in "root" added at all).This is usually fine, however, in our application, I am trying to modularize the download capabilities and embed it on multiple subpages (up to 10 or more times), hence, it will become an issue, since every embedding will produce a different download.
I am using shiny version 1.1.0.
Here is an example app illustrating my issue:
app.py
download.py
This app will produce two buttons. When hovering over the first button (that uses the
@render.download
functionality) then the link will look likesession/<id>/download/dwnld?w=
, however, the second button (@session.download
) will produce a namespaced subpath that looks likesession/<id>/download/download_session-dwnld?w=
(see screenshot below of the DOM).This namespaced variation is important when implementing multiple download buttons that are being generated with a module. Otherwise a click on any of the generated module download buttons will trigger the "last" registered download handler function.
To illustrate this, see this modified example:
This should output (notification) "Foo" on the first button, "Bar" on the second button, and "Baz" on the third button. However, when clicking on the first button I get:
Additionaly, as you can see, the session namespace is a entirely different one (the namespace of the third button). This flaw can be quite dangerous, as it messes up everything.
On top of this, the
@render.download
does not allow me to specify an "id" as it was the case with@session.download
, which can be used to override the automatic linking of a download handler function to a download button.As a workaround I managed to use
@session.download
in combination with theid=
parameter with a pinch of ResolvedId magic, however, this inconsistency and also the deprecation warning in@session.download
gives me quite some headaches for the future.See the following simplified snippet of what I mean by this previous sentence:
With this ResolvedId method, I am fully in control which methods I want to tie to which button.
How to resolve this?
I think it would be best to...
@render.download
properly namespaces the button/subpaths similar to@session.download
id=
parameter in@render.download
What do you guys think?
The text was updated successfully, but these errors were encountered: