Commits

Greg Von Kuster  committed 255f4bd

More fixes for Galaxy <-> tool shed communication.

  • Participants
  • Parent commits af8f588

Comments (0)

Files changed (3)

File lib/galaxy/web/controllers/admin.py

     @web.expose
     @web.require_admin
     def check_for_updates( self, trans, **kwd ):
+        # Send a request to the relevant tool shed to see if there are any updates.
         repository = get_repository( trans, kwd[ 'id' ] )
-        galaxy_url = url_for( '', qualified=True )
-        # Send a request to the relevant tool shed to see if there are any updates.
-        # TODO: Fix this to use url_for to support locally hosted tool sheds.
-        url = 'http://%s/repository/check_for_updates?galaxy_url=%s&name=%s&owner=%s&changeset_revision=%s&webapp=galaxy' % \
-            ( repository.tool_shed, galaxy_url, repository.name, repository.owner, repository.changeset_revision )
+        tool_shed_url = get_url_from_repository_tool_shed( trans, repository )
+        url = '%s/repository/check_for_updates?galaxy_url=%s&name=%s&owner=%s&changeset_revision=%s&webapp=galaxy' % \
+            ( tool_shed_url, url_for( '', qualified=True ), repository.name, repository.owner, repository.changeset_revision )
         return trans.response.send_redirect( url )
     @web.expose
     @web.require_admin
                                           trans.model.ToolShedRepository.table.c.owner == owner,
                                           trans.model.ToolShedRepository.table.c.changeset_revision == changeset_revision ) ) \
                            .first()
+def get_url_from_repository_tool_shed( trans, repository ):
+    # The stored value of repository.tool_shed is something like:
+    # toolshed.g2.bx.psu.edu
+    # We need the URL to this tool shed, which is something like:
+    # http://toolshed.g2.bx.psu.edu/
+    for shed_name, shed_url in trans.app.tool_shed_registry.tool_sheds.items():
+        if shed_url.find( repository.tool_shed ) >= 0:
+            if shed_url.endswith( '/' ):
+                shed_url = shed_url.rstrip( '/' )
+            return shed_url
+    # The tool shed from which the repository was originally
+    # installed must no longer be configured in tool_sheds_conf.xml.
+    return None
+                                    

File lib/galaxy/web/controllers/workflow.py

             import_button = True
         if tool_shed_url and not import_button:
             # Use urllib (send another request to the tool shed) to retrieve the workflow.
-            workflow_url = 'http://%s/workflow/import_workflow?repository_metadata_id=%s&workflow_name=%s&webapp=%s&open_for_url=true' % \
+            workflow_url = '%s/workflow/import_workflow?repository_metadata_id=%s&workflow_name=%s&webapp=%s&open_for_url=true' % \
                 ( tool_shed_url, repository_metadata_id, tool_shed_encode( workflow_name ), webapp )
             response = urllib2.urlopen( workflow_url )
             workflow_text = response.read()
                             for shed_name, shed_url in trans.app.tool_shed_registry.tool_sheds.items():
                                 if shed_url.endswith( '/' ):
                                     shed_url = shed_url.rstrip( '/' )
-                                    url = '%s/repository/find_tools?galaxy_url=%s&webapp=%s' % ( shed_url, trans.request.host, webapp )
+                                    url = '%s/repository/find_tools?galaxy_url=%s&webapp=%s' % ( shed_url, url_for( '', qualified=True ), webapp )
                                     if missing_tool_tups:
                                         url += '&tool_id='
                                     for missing_tool_tup in missing_tool_tups:
                     if tool_shed_url:
                         # We've received the textual representation of a workflow from a Galaxy tool shed.
                         message = "Workflow <b>%s</b> imported successfully." % workflow.name
-                        # TODO: support https in the following url.
-                        url = 'http://%s/workflow/view_workflow?repository_metadata_id=%s&workflow_name=%s&webapp=%s&message=%s' % \
+                        url = '%s/workflow/view_workflow?repository_metadata_id=%s&workflow_name=%s&webapp=%s&message=%s' % \
                             ( tool_shed_url, repository_metadata_id, tool_shed_encode( workflow_name ), webapp, message )
                         return trans.response.send_redirect( url )
                     elif installed_repository_file:

File lib/galaxy/webapps/community/controllers/workflow.py

                 to_file.write( to_json_string( workflow_data ) )
                 return open( tmp_fname )
             galaxy_url = trans.get_cookie( name='toolshedgalaxyurl' )
-            # TODO: support https in the following url.
-            url = 'http://%s/workflow/import_workflow?tool_shed_url=%s&repository_metadata_id=%s&workflow_name=%s&webapp=%s' % \
-                ( galaxy_url, trans.request.host, repository_metadata_id, encode( workflow_name ), webapp )
+            url = '%s/workflow/import_workflow?tool_shed_url=%s&repository_metadata_id=%s&workflow_name=%s&webapp=%s' % \
+                ( galaxy_url, url_for( '', qualified=True ), repository_metadata_id, encode( workflow_name ), webapp )
             return trans.response.send_redirect( url )
         return trans.response.send_redirect( web.url_for( controller='workflow',
                                                           action='view_workflow',