Dear Galaxy Developers,
This post went unanswered could I re-submit in a hope if there is any guy out there who could stop me pulling my few left hairs.
My tool meant to load up (in a dropdown) some custom data from a non-galaxy database for the user to select and submit a job. I am using dynamic_options for loading such dynamic values, however to restrict data for a logged-in user I
 need to  know the user id. 
So far I have tried many things including setting dynamic_options="load_dynamic_values($__user_id__) in the xml wrapper but it did not work. I know $__user_id__  can be passed to the tool as a command line arguments, however, my issue
 is to read user id even before the execution of main tool.
Thanks for your help guys.
I have also tried following code in a hope to grab the webapp session.
      ini_file = '/galaxy-dist/universe_wsgi.ini'
      conf_parser = ConfigParser.ConfigParser( {'here':os.getcwd()} )
      conf_parser.read( ini_file )
      configuration = {}
      for key, value in conf_parser.items( "app:main" ):
            configuration[key] = value
      global_conf = { '__file__' : ini_file }
app = galaxy.app.UniverseApplication(**configuration )
But this generates following error. 
UnboundExecutionError: Parent instance <History at 0x581cdd0> is not bound to a Session; lazy load operation of attribute 'active_datasets' cannot
 proceed
Regards
Matloob Khushi