Skip to content

Commit

Permalink
Preserve original request params as nested dict
Browse files Browse the repository at this point in the history
and use them in final POST request
  • Loading branch information
wm75 committed Feb 9, 2024
1 parent 561bf92 commit eef015d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/galaxy/webapps/galaxy/controllers/async.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,16 @@ def index(self, trans, tool_id=None, data_secret=None, **kwd):
# ignore any other params that may have been passed by the remote
# server with the exception of STATUS and URL;
# if name, info, dbkey and data_type are not handled via incoming params,
# use the metadata from the already existing dataset
# use the metadata from the already existing dataset;
# preserve original params under nested dict
params_dict = dict(
STATUS=params.STATUS,
URL=params.URL,
name=data.name,
info=data.info,
dbkey=data.dbkey,
data_type=data.ext,
incoming_request_params=params.__dict__.copy(),
)
if tool.input_translator:
tool.input_translator.translate(params)
Expand Down
3 changes: 3 additions & 0 deletions lib/galaxy/webapps/galaxy/controllers/tool_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ def __tool_404__():

# execute tool without displaying form (used for datasource tools)
params = galaxy.util.Params(kwd, sanitize=False)
if tool.tool_type == "data_source":
# preserve original params sent by the remote server as extra dict
params.update({"incoming_request_params": params.__dict__.copy()})
# do param translation here, used by datasource tools
if tool.input_translator:
tool.input_translator.translate(params)
Expand Down
6 changes: 5 additions & 1 deletion tools/data_source/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ def __main__():
if URL_method == "get":
page = urlopen(cur_URL, timeout=DEFAULT_SOCKET_TIMEOUT)
elif URL_method == "post":
page = urlopen(cur_URL, urlencode(params["param_dict"]).encode("utf-8"), timeout=DEFAULT_SOCKET_TIMEOUT)
page = urlopen(
cur_URL,
urlencode(params["param_dict"]["incoming_request_params"]).encode("utf-8"),
timeout=DEFAULT_SOCKET_TIMEOUT
)
except Exception as e:
sys.exit("The remote data source application may be off line, please try again later. Error: %s" % str(e))
if max_file_size:
Expand Down

0 comments on commit eef015d

Please sign in to comment.