# HG changeset patch -- Bitbucket.org # Project galaxy-dist # URL http://bitbucket.org/galaxy/galaxy-dist/overview # User Nate Coraor <nate@bx.psu.edu> # Date 1279659120 14400 # Node ID 8ffcaf3d9a0c16d080801f3f81104e829403da41 # Parent 7e63649e96b5788bdd72e3d639fca1e8153c2775 Patch from Brad Chapman: Handle URLs for uploading in the case where Galaxy is served under a prefix and nginx is used to handle the uploads. --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -437,10 +437,16 @@ class Tool: self.check_values = util.string_as_bool( input_elem.get("check_values", "true") ) self.nginx_upload = util.string_as_bool( input_elem.get( "nginx_upload", "false" ) ) self.action = input_elem.get( 'action', '/tool_runner/index' ) + # If we have an nginx upload, save the action as a tuple instead of + # a string. The actual action needs to get url_for run to add any + # prefixes, and we want to avoid adding the prefix to the + # nginx_upload_path. This logic is handled in the tool_form.mako + # template. if self.nginx_upload and self.app.config.nginx_upload_path: if '?' in urllib.unquote_plus( self.action ): raise Exception( 'URL parameters in a non-default tool action can not be used in conjunction with nginx upload. Please convert them to hidden POST parameters' ) - self.action = self.app.config.nginx_upload_path + '?nginx_redir=' + urllib.unquote_plus( self.action ) + self.action = (self.app.config.nginx_upload_path + '?nginx_redir=', + urllib.unquote_plus(self.action)) self.target = input_elem.get( "target", "galaxy_main" ) self.method = input_elem.get( "method", "post" ) # Parse the actual parameters --- a/templates/tool_form.mako +++ b/templates/tool_form.mako @@ -200,14 +200,22 @@ function checkUncheckAll( name, check ) <br/> %endif - <div class="toolForm" id="${tool.id}"> + ## handle calculating the redict url for the special case where we have nginx proxy + ## upload and need to do url_for on the redirect portion of the tool action + <% + try: + tool_url = h.url_for(tool.action) + except AttributeError: + assert len(tool.action) == 2 + tool_url = tool.action[0] + h.url_for(tool.action[1]) + %><div class="toolForm" id="${tool.id}"> %if tool.has_multiple_pages: <div class="toolFormTitle">${tool.name} (step ${tool_state.page+1} of ${tool.npages})</div> %else: <div class="toolFormTitle">${tool.name}</div> %endif <div class="toolFormBody"> - <form id="tool_form" name="tool_form" action="${h.url_for( tool.action )}" enctype="${tool.enctype}" target="${tool.target}" method="${tool.method}"> + <form id="tool_form" name="tool_form" action="${tool_url}" enctype="${tool.enctype}" target="${tool.target}" method="${tool.method}"><input type="hidden" name="tool_id" value="${tool.id}"><input type="hidden" name="tool_state" value="${util.object_to_string( tool_state.encode( tool, app ) )}"><input type="hidden" name="tool_id" value="${tool.id}"><input type="hidden" name="tool_state" value="${util.object_to_string( tool_state.encode( tool, app ) )}"> %if tool.display_by_page[tool_state.page]: