details: http://www.bx.psu.edu/hg/galaxy/rev/2950f021fc0c changeset: 2901:2950f021fc0c user: Kanwei Li <kanwei@gmail.com> date: Wed Oct 21 14:16:38 2009 -0400 description: revert root.py (backward compatibility issue) 1 file(s) affected in this change: lib/galaxy/web/controllers/root.py diffs (58 lines): diff -r 197ff8461127 -r 2950f021fc0c lib/galaxy/web/controllers/root.py --- a/lib/galaxy/web/controllers/root.py Wed Oct 21 11:53:29 2009 -0400 +++ b/lib/galaxy/web/controllers/root.py Wed Oct 21 14:16:38 2009 -0400 @@ -139,13 +139,49 @@ @web.expose def display( self, trans, id=None, hid=None, tofile=None, toext=".txt", **kwd ): """ - Backward compatibility. + Returns data directly into the browser. + Sets the mime-type according to the extension """ - if tofile: - to_ext = toext + if hid is not None: + try: + hid = int( hid ) + except: + return "hid '%s' is invalid" %str( hid ) + history = trans.get_history() + for dataset in history.datasets: + if dataset.hid == hid: + data = dataset + break + else: + raise Exception( "No dataset with hid '%d'" % hid ) else: - to_ext = None - return trans.webapp.controllers['dataset'].display( trans, encoded_id=id, to_ext=to_ext ) + try: + data = self.app.model.HistoryDatasetAssociation.get( id ) + except: + return "Dataset id '%s' is invalid" %str( id ) + if data: + user, roles = trans.get_user_and_roles() + if trans.app.security_agent.can_access_dataset( roles, data.dataset ): + mime = trans.app.datatypes_registry.get_mimetype_by_extension( data.extension.lower() ) + trans.response.set_content_type(mime) + if tofile: + fStat = os.stat(data.file_name) + trans.response.headers['Content-Length'] = int(fStat.st_size) + if toext[0:1] != ".": + toext = "." + toext + valid_chars = '.,^_-()[]0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' + fname = data.name + fname = ''.join(c in valid_chars and c or '_' for c in fname)[0:150] + trans.response.headers["Content-Disposition"] = "attachment; filename=GalaxyHistoryItem-%s-[%s]%s" % (data.hid, fname, toext) + trans.log_event( "Display dataset id: %s" % str(id) ) + try: + return open( data.file_name ) + except: + return "This dataset contains no content" + else: + return "You are not allowed to access this dataset" + else: + return "No dataset with id '%s'" % str( id ) @web.expose def display_child(self, trans, parent_id=None, designation=None, tofile=None, toext=".txt"):