commit/galaxy-central: carlfeberhard: Fix deleted check in api/histories.delete, better error reporting in base controller get_object
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/238988fc5d2a/ Changeset: 238988fc5d2a User: carlfeberhard Date: 2013-07-11 18:18:51 Summary: Fix deleted check in api/histories.delete, better error reporting in base controller get_object Affected #: 2 files diff -r 4cc057df762c219406af27dd04ac725a07a5a6eb -r 238988fc5d2a963685e7ab12a0282f89a8bca430 lib/galaxy/web/base/controller.py --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -113,21 +113,25 @@ try: decoded_id = trans.security.decode_id( id ) except: - raise MessageException( "Malformed %s id ( %s ) specified, unable to decode" % ( class_name, str( id ) ), type='error' ) + raise MessageException( "Malformed %s id ( %s ) specified, unable to decode" + % ( class_name, str( id ) ), type='error' ) try: item_class = self.get_class( class_name ) assert item_class is not None item = trans.sa_session.query( item_class ).get( decoded_id ) assert item is not None - except: - log.exception( "Invalid %s id ( %s ) specified" % ( class_name, id ) ) + except Exception, exc: + log.exception( "Invalid %s id ( %s ) specified: %s" % ( class_name, id, str( exc ) ) ) raise MessageException( "Invalid %s id ( %s ) specified" % ( class_name, id ), type="error" ) + if check_ownership or check_accessible: self.security_check( trans, item, check_ownership, check_accessible ) if deleted == True and not item.deleted: - raise ItemDeletionException( '%s "%s" is not deleted' % ( class_name, getattr( item, 'name', id ) ), type="warning" ) + raise ItemDeletionException( '%s "%s" is not deleted' + % ( class_name, getattr( item, 'name', id ) ), type="warning" ) elif deleted == False and item.deleted: - raise ItemDeletionException( '%s "%s" is deleted' % ( class_name, getattr( item, 'name', id ) ), type="warning" ) + raise ItemDeletionException( '%s "%s" is deleted' + % ( class_name, getattr( item, 'name', id ) ), type="warning" ) return item # this should be here - but catching errors from sharable item controllers that *should* have SharableItemMixin @@ -190,11 +194,11 @@ check_ownership=check_ownership, check_accessible=check_accessible, deleted=deleted ) except ItemDeletionException, e: - raise HTTPBadRequest( detail="Invalid %s id ( %s ) specified" % ( class_name, str( id ) ) ) + raise HTTPBadRequest( detail="Invalid %s id ( %s ) specified: %s" % ( class_name, str( id ), str( e ) ) ) except MessageException, e: raise HTTPBadRequest( detail=e.err_msg ) except Exception, e: - log.exception( "Execption in get_object check for %s %s:" % ( class_name, str( id ) ) ) + log.exception( "Execption in get_object check for %s %s: %s" % ( class_name, str( id ), str( e ) ) ) raise HTTPInternalServerError( comment=str( e ) ) def validate_in_users_and_groups( self, trans, payload ): @@ -280,8 +284,10 @@ def get_history( self, trans, id, check_ownership=True, check_accessible=False, deleted=None ): """Get a History from the database by id, verifying ownership.""" - history = self.get_object( trans, id, 'History', check_ownership=check_ownership, check_accessible=check_accessible, deleted=deleted ) - return self.security_check( trans, history, check_ownership, check_accessible ) + history = self.get_object( trans, id, 'History', + check_ownership=check_ownership, check_accessible=check_accessible, deleted=deleted ) + history = self.security_check( trans, history, check_ownership, check_accessible ) + return history def get_history_datasets( self, trans, history, show_deleted=False, show_hidden=False, show_purged=False ): """ Returns history's datasets. """ diff -r 4cc057df762c219406af27dd04ac725a07a5a6eb -r 238988fc5d2a963685e7ab12a0282f89a8bca430 lib/galaxy/webapps/galaxy/api/histories.py --- a/lib/galaxy/webapps/galaxy/api/histories.py +++ b/lib/galaxy/webapps/galaxy/api/histories.py @@ -2,6 +2,10 @@ API operations on a history. """ +import pkg_resources +pkg_resources.require( "Paste" ) +from paste.httpexceptions import HTTPBadRequest + from galaxy import web from galaxy.util import string_as_bool, restore_text from galaxy.util.sanitize_html import sanitize_html @@ -75,9 +79,13 @@ history_data = self.get_history_dict( trans, history ) history_data[ 'contents_url' ] = url_for( 'history_contents', history_id=history_id ) + except HTTPBadRequest, bad_req: + trans.response.status = 400 + return str( bad_req ) + except Exception, e: msg = "Error in history API at showing history detail: %s" % ( str( e ) ) - log.error( msg, exc_info=True ) + log.exception( msg, exc_info=True ) trans.response.status = 500 return msg @@ -117,7 +125,7 @@ purge = string_as_bool( kwd['payload'].get( 'purge', False ) ) try: - history = self.get_history( trans, history_id, check_ownership=True, check_accessible=False, deleted=True ) + history = self.get_history( trans, history_id, check_ownership=True, check_accessible=False ) except Exception, e: return str( e ) Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org