On 30 August 2012 14:23, Mutlu Dogruel <mutludogruel@gmail.com> wrote:

On 29 August 2012 21:11, Nate Coraor <nate@bx.psu.edu> wrote:
On Aug 24, 2012, at 9:48 AM, Mutlu Dogruel wrote:

> Hi folk,
>
> Do you know any method for reading (the extended) WSGI HTTP headers
> from a custom tool?
>
> If I put some debugging lines in
> $galaxy/lib/galaxy/web/framework/middleware/xforwardedhost.py, I can
> read the HTTP headers I want. But I need to access them under
> tools/my_script.py. Is there a way to reach the "webapp"s http headers
> from there?

Hi Mutlu,

Do you mean the headers at the time of tool execution?  Running tools (jobs) is intentionally decoupled from the state of the front end.  However, you could modify the tool submission to store the header as a tool parameter and pass it in the command template.

--nate

>
> Thanks.
> Mutlu
> ___________________________________________________________
> Please keep all replies on the list by using "reply all"
> in your mail client.  To manage your subscriptions to this
> and other Galaxy lists, please use the interface at:
>
>  http://lists.bx.psu.edu/



Thanks for the reply. Yes, this is what I am trying to achieve. But in my case, I need to read the headers before the tool is run, and to be more precise, just before dynamic_options creates a selection list. Because it's the dynamic_options script that needs the http header values.

Essentially, I need to get some AWS keys from the http headers. We inject AWS keys and secrets into http headers on a proxy server that Galaxy is sitting behind. I have a customised upload.xml and upload.py for managing downloads from S3 buckets (I kept the original upload scripts as well). In this scenario, a list of available, permitted S3 files are generated by dynamics_options, according to the AWS keys. The user-selected file is later downloaded from Amazon using its URL. This is handled by Galaxy's native URL downloader. It works fine if I read the AWS keys from a local file, but of course, the keys do not have to be static.

I just started to look into lib/galaxy/tools/parameters/dynamic_options.py, can this be a good starting point?

Thanks,
Best regards,
--
Mutlu



Hi, for those interested, this is how I solved this problem: I modified web/framework/__init__.py for setting the extra http headers we wanted. I added new objects to the app.py for holding the http headers sent by the proxy. Otherwise, it wasn't possible to retrieve them from os.environ at this depth of the code. Then I modified tools/parameters/basic.py for injecting these keys into the self.dynamic_options string variable that holds the user function's name.
--
Mutlu