commit/galaxy-central: natefoo: Fix for the mime type when a dataset instance's extension is None.
1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/e28ebc25b2e7/ changeset: e28ebc25b2e7 user: natefoo date: 2011-09-28 16:56:30 summary: Fix for the mime type when a dataset instance's extension is None. affected #: 4 files (-1 bytes) --- a/lib/galaxy/model/__init__.py Wed Sep 28 10:47:54 2011 -0400 +++ b/lib/galaxy/model/__init__.py Wed Sep 28 10:56:30 2011 -0400 @@ -862,7 +862,11 @@ self.datatype.set_raw_data(self, data) def get_mime( self ): """Returns the mime type of the data""" - return datatypes_registry.get_mimetype_by_extension( self.extension.lower() ) + try: + return datatypes_registry.get_mimetype_by_extension( self.extension.lower() ) + except AttributeError: + # extension is None + return 'data' def is_multi_byte( self ): """Data consists of multi-byte characters""" return self.dataset.is_multi_byte() --- a/lib/galaxy/web/controllers/dataset.py Wed Sep 28 10:47:54 2011 -0400 +++ b/lib/galaxy/web/controllers/dataset.py Wed Sep 28 10:56:30 2011 -0400 @@ -358,8 +358,7 @@ else: return trans.show_error_message( "Could not find '%s' on the extra files path %s." % ( filename, file_path ) ) - mime = trans.app.datatypes_registry.get_mimetype_by_extension( data.extension.lower() ) - trans.response.set_content_type(mime) + trans.response.set_content_type(data.get_mime()) trans.log_event( "Display dataset id: %s" % str( dataset_id ) ) if to_ext or isinstance(data.datatype, datatypes.binary.Binary): # Saving the file, or binary file @@ -691,8 +690,7 @@ # If data is binary or an image, stream without template; otherwise, use display template. # TODO: figure out a way to display images in display template. if isinstance(dataset.datatype, datatypes.binary.Binary) or isinstance(dataset.datatype, datatypes.images.Image) or isinstance(dataset.datatype, datatypes.images.Html): - mime = trans.app.datatypes_registry.get_mimetype_by_extension( dataset.extension.lower() ) - trans.response.set_content_type( mime ) + trans.response.set_content_type( data.get_mime() ) return open( dataset.file_name ) else: # Get rating data. --- a/lib/galaxy/web/controllers/library_common.py Wed Sep 28 10:47:54 2011 -0400 +++ b/lib/galaxy/web/controllers/library_common.py Wed Sep 28 10:56:30 2011 -0400 @@ -1404,8 +1404,7 @@ kwd['do_action'] = 'zip' return self.act_on_multiple_datasets( trans, cntrller, library_id, ldda_ids=[id,], **kwd ) else: - mime = trans.app.datatypes_registry.get_mimetype_by_extension( ldda.extension.lower() ) - trans.response.set_content_type( mime ) + trans.response.set_content_type( ldda.get_mime() ) fStat = os.stat( ldda.file_name ) trans.response.headers[ 'Content-Length' ] = int( fStat.st_size ) valid_chars = '.,^_-()[]0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' --- a/lib/galaxy/web/controllers/root.py Wed Sep 28 10:47:54 2011 -0400 +++ b/lib/galaxy/web/controllers/root.py Wed Sep 28 10:56:30 2011 -0400 @@ -241,8 +241,7 @@ if data: current_user_roles = trans.get_current_user_roles() if trans.app.security_agent.can_access_dataset( current_user_roles, data.dataset ): - mime = trans.app.datatypes_registry.get_mimetype_by_extension( data.extension.lower() ) - trans.response.set_content_type(mime) + trans.response.set_content_type(data.get_mime()) if tofile: fStat = os.stat(data.file_name) trans.response.headers['Content-Length'] = int(fStat.st_size) 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)
-
Bitbucket