Hi Damion,

In the genomespace exporter case, the call to “dynamic_options="galaxy_code_get_genomespace_folders( genomespace_site = 'prod', trans=__trans__, value=__value__, input_dataset=input1, base_url=base_url )”  is passing in trans, which it is using to determine user and an attribute of the user. You could then check to see if trans.user is not None, and then get trans.user.username. 

You may be able to access user or username here by the more recently added “__user__” or even “__user_name__” / “__user_id__” / “__user_email__" variables directly, but I didn’t test that they were available in this dynamic_options context example (if they are available, they would be preferred over accessing trans).

For accessing a user’s API key, this trello card is of interest: https://trello.com/c/hL4NYsSp/2108-request-from-jxtx-provide-consistent-interface-to-tools-for-communicating-with-the-api. Of course the Key can be obtained directly from the user object as well.


Hope this helps,

Dan


On Oct 10, 2014, at 12:02 PM, Dooley, Damion <Damion.Dooley@bccdc.ca> wrote:

Hi Dan,

I'd like to get the user's galaxy user name directly - but the  <code file="..."> that drives my dynamic_options select list has no access to any information in a galaxy's user session, right?  (Ultimately I'm trying to get the dynamic_options code to make galaxy api calls using the user's api key.)  I saw the GenomeSpace tool earlier - but got the impression that a user was entering their genome login in the tool form.  I was hoping just to get a user's galaxy id without any re-entry of it.

p.s. Its been really great getting advice from all of you; I hope to contribute likewise.

d.

Hsiao lab, BC Public Health Microbiology & Reference Laboratory, BC Centre for Disease Control
655 West 12th Avenue, Vancouver, British Columbia, V5Z 4R4 Canada
________________________________________
From: Daniel Blankenberg [dan@bx.psu.edu]
Sent: Friday, October 10, 2014 8:08 AM
To: Dooley, Damion
Cc: galaxy-dev@lists.bx.psu.edu
Subject: Re: [galaxy-dev] Tool development: Is it possible to pass a user's id in dynamic_options() parameter?

Hi Damion,

Text fields are not currently able to be populated by dynamic_options, but in a dynamic_options select list you could access the user’s username directly. If you want the user to be able to override it, you could have a conditionally used empty text box that your tool defaults to using when it is populated.

An example that you might want to look at could be the GenomeSpace Export tool (tools/genomespace/genomespace_exporter.*), which queries the GenomeSpace API to get a list of available folders for export for a specific user using attributes of the current user’s preferences (GenomeSpace username and token). It generates a drill_down type select parameter, but the same can be done for a standard select list.


Thanks for using Galaxy,

Dan