[hg] galaxy 2418: Bug fix for undeleting deleted history items.
details: http://www.bx.psu.edu/hg/galaxy/rev/7414f90d7eae changeset: 2418:7414f90d7eae user: Greg Von Kuster <greg@bx.psu.edu> date: Tue May 26 16:35:23 2009 -0400 description: Bug fix for undeleting deleted history items. 1 file(s) affected in this change: lib/galaxy/web/controllers/dataset.py diffs (52 lines): diff -r 76890d7fb3dd -r 7414f90d7eae lib/galaxy/web/controllers/dataset.py --- a/lib/galaxy/web/controllers/dataset.py Tue May 26 14:59:40 2009 -0400 +++ b/lib/galaxy/web/controllers/dataset.py Tue May 26 16:35:23 2009 -0400 @@ -127,27 +127,31 @@ return trans.show_error_message( "You are not allowed to access this dataset" ) def _undelete( self, trans, id ): - if isinstance( id, type( 1 ) ): - history = trans.get_history() - data = self.app.model.HistoryDatasetAssociation.get( id ) - if data and data.undeletable: - # Walk up parent datasets to find the containing history - topmost_parent = data - while topmost_parent.parent: - topmost_parent = topmost_parent.parent - assert topmost_parent in history.datasets, "Data does not belong to current history" - # Mark undeleted - data.mark_undeleted() - self.app.model.flush() - trans.log_event( "Dataset id %s has been undeleted" % str(id) ) - return True + try: + id = int( id ) + except ValueError, e: + return False + history = trans.get_history() + data = self.app.model.HistoryDatasetAssociation.get( id ) + if data and data.undeletable: + # Walk up parent datasets to find the containing history + topmost_parent = data + while topmost_parent.parent: + topmost_parent = topmost_parent.parent + assert topmost_parent in history.datasets, "Data does not belong to current history" + # Mark undeleted + data.mark_undeleted() + self.app.model.flush() + trans.log_event( "Dataset id %s has been undeleted" % str(id) ) + return True return False @web.expose def undelete( self, trans, id ): - self._undelete( trans, id ) - return trans.response.send_redirect( web.url_for( controller='root', action='history', show_deleted = True ) ) - + if self._undelete( trans, id ): + return trans.response.send_redirect( web.url_for( controller='root', action='history', show_deleted = True ) ) + raise "Error undeleting" + @web.expose def undelete_async( self, trans, id ): if self._undelete( trans, id ):
participants (1)
-
Greg Von Kuster