details: http://www.bx.psu.edu/hg/galaxy/rev/853046b87a5c changeset: 3718:853046b87a5c user: Dan Blankenberg <dan@bx.psu.edu> date: Fri Apr 30 10:15:42 2010 -0400 description: Fix for backwards compatibility of HDAs being referenced as an integer. A hash that happened to be an integer would previously cause error. diffstat: lib/galaxy/web/base/controller.py | 12 ++++++++---- lib/galaxy/web/controllers/dataset.py | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diffs (44 lines): diff -r c09a8456b63e -r 853046b87a5c lib/galaxy/web/base/controller.py --- a/lib/galaxy/web/base/controller.py Thu Apr 29 19:57:00 2010 -0400 +++ b/lib/galaxy/web/base/controller.py Fri Apr 30 10:15:42 2010 -0400 @@ -122,10 +122,14 @@ """ Get an HDA object by id. """ # DEPRECATION: We still support unencoded ids for backward compatibility try: - dataset_id = int( dataset_id ) - except ValueError: - dataset_id = trans.security.decode_id( dataset_id ) - data = trans.sa_session.query( trans.model.HistoryDatasetAssociation ).get( dataset_id ) + data = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( trans.security.decode_id( dataset_id ) ) + if data is None: + raise ValueError( 'Invalid reference dataset id: %s.' % dataset_id ) + except: + try: + data = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( int( dataset_id ) ) + except: + data = None if not data: raise paste.httpexceptions.HTTPRequestRangeNotSatisfiable( "Invalid dataset id: %s." % str( dataset_id ) ) if check_ownership: diff -r c09a8456b63e -r 853046b87a5c lib/galaxy/web/controllers/dataset.py --- a/lib/galaxy/web/controllers/dataset.py Thu Apr 29 19:57:00 2010 -0400 +++ b/lib/galaxy/web/controllers/dataset.py Fri Apr 30 10:15:42 2010 -0400 @@ -307,10 +307,14 @@ composite_extensions.append('html') # for archiving composite datatypes # DEPRECATION: We still support unencoded ids for backward compatibility try: - dataset_id = int( dataset_id ) - except ValueError: - dataset_id = trans.security.decode_id( dataset_id ) - data = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( dataset_id ) + data = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( trans.security.decode_id( dataset_id ) ) + if data is None: + raise ValueError( 'Invalid reference dataset id: %s.' % dataset_id ) + except: + try: + data = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( int( dataset_id ) ) + except: + data = None if not data: raise paste.httpexceptions.HTTPRequestRangeNotSatisfiable( "Invalid reference dataset id: %s." % str( dataset_id ) ) current_user_roles = trans.get_current_user_roles()