[hg] galaxy 3265: Fix library uploads when using the nginx uploa...
details: http://www.bx.psu.edu/hg/galaxy/rev/1dddb95579a1 changeset: 3265:1dddb95579a1 user: Nate Coraor <nate@bx.psu.edu> date: Mon Jan 25 11:08:21 2010 -0500 description: Fix library uploads when using the nginx upload module (redirect URL cannot include GET params) diffstat: lib/galaxy/tools/__init__.py | 9 +++++---- lib/galaxy/web/controllers/library.py | 3 +++ lib/galaxy/web/controllers/library_admin.py | 4 ++++ lib/galaxy/web/controllers/library_common.py | 9 ++++++++- 4 files changed, 20 insertions(+), 5 deletions(-) diffs (67 lines): diff -r 17db30ce0486 -r 1dddb95579a1 lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py Mon Jan 25 10:01:04 2010 -0500 +++ b/lib/galaxy/tools/__init__.py Mon Jan 25 11:08:21 2010 -0500 @@ -5,7 +5,7 @@ pkg_resources.require( "simplejson" ) -import logging, os, string, sys, tempfile, glob, shutil, types +import logging, os, string, sys, tempfile, glob, shutil, types, urllib import simplejson import binascii from UserDict import DictMixin @@ -432,10 +432,11 @@ # Handle properties of the input form 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 self.nginx_upload and self.app.config.nginx_upload_path: - self.action = input_elem.get( "action", self.app.config.nginx_upload_path + "?nginx_redir=/tool_runner/index" ) - else: - self.action = input_elem.get( "action", "/tool_runner/index") + 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.target = input_elem.get( "target", "galaxy_main" ) self.method = input_elem.get( "method", "post" ) # Parse the actual parameters diff -r 17db30ce0486 -r 1dddb95579a1 lib/galaxy/web/controllers/library.py --- a/lib/galaxy/web/controllers/library.py Mon Jan 25 10:01:04 2010 -0500 +++ b/lib/galaxy/web/controllers/library.py Mon Jan 25 11:08:21 2010 -0500 @@ -34,3 +34,6 @@ default_action=params.get( 'default_action', None ), msg=msg, messagetype=messagetype ) + @web.expose + def upload_library_dataset( self, trans, library_id, folder_id, **kwd ): + return trans.webapp.controllers[ 'library_common' ].upload_library_dataset( trans, 'library', library_id, folder_id, **kwd ) diff -r 17db30ce0486 -r 1dddb95579a1 lib/galaxy/web/controllers/library_admin.py --- a/lib/galaxy/web/controllers/library_admin.py Mon Jan 25 10:01:04 2010 -0500 +++ b/lib/galaxy/web/controllers/library_admin.py Mon Jan 25 11:08:21 2010 -0500 @@ -239,3 +239,7 @@ id=library_id, msg=msg, messagetype=status ) ) + @web.expose + @web.require_admin + def upload_library_dataset( self, trans, library_id, folder_id, **kwd ): + return trans.webapp.controllers[ 'library_common' ].upload_library_dataset( trans, 'library_admin', library_id, folder_id, **kwd ) diff -r 17db30ce0486 -r 1dddb95579a1 lib/galaxy/web/controllers/library_common.py --- a/lib/galaxy/web/controllers/library_common.py Mon Jan 25 10:01:04 2010 -0500 +++ b/lib/galaxy/web/controllers/library_common.py Mon Jan 25 11:08:21 2010 -0500 @@ -701,7 +701,14 @@ # If we're using nginx upload, override the form action action = web.url_for( controller='library_common', action='upload_library_dataset', cntrller=cntrller ) if upload_option == 'upload_file' and trans.app.config.nginx_upload_path: - action = web.url_for( trans.app.config.nginx_upload_path ) + '?nginx_redir=' + action + # url_for is intentionally not used on the base URL here - + # nginx_upload_path is expected to include the proxy prefix if the + # administrator intends for it to be part of the URL. We also + # redirect to the library or library_admin controller rather than + # library_common because GET arguments can't be used in conjunction + # with nginx upload (nginx can't do percent decoding without a + # bunch of hacky rewrite rules). + action = trans.app.config.nginx_upload_path + '?nginx_redir=' + web.url_for( controller=cntrller, action='upload_library_dataset' ) return trans.fill_template( '/library/common/upload.mako', cntrller=cntrller, upload_option=upload_option,
participants (1)
-
Greg Von Kuster