details: http://www.bx.psu.edu/hg/galaxy/rev/e6324f395d26 changeset: 2829:e6324f395d26 user: jeremy goecks <jeremy.goecks@emory.edu> date: Mon Oct 05 17:38:54 2009 -0400 description: Added method get_display_name() to History and HistoryDatasetAssociation objects; these methods return unicode objects that can be used to display non-ascii characters. Fixes #181 4 file(s) affected in this change: lib/galaxy/model/__init__.py lib/galaxy/web/controllers/history.py templates/dataset/edit_attributes.mako templates/root/history.mako diffs (100 lines): diff -r f648d6dec544 -r e6324f395d26 lib/galaxy/model/__init__.py --- a/lib/galaxy/model/__init__.py Mon Oct 05 15:07:20 2009 -0400 +++ b/lib/galaxy/model/__init__.py Mon Oct 05 17:38:54 2009 -0400 @@ -245,6 +245,12 @@ def activatable_datasets( self ): # This needs to be a list return [ hda for hda in self.datasets if not hda.dataset.deleted ] + def get_display_name( self ): + ## History name can be either a string or a unicode object. If string, convert to unicode object assuming 'utf-8' format. + history_name = self.name + if isinstance(history_name, str): + history_name = unicode(history_name, 'utf-8') + return history_name class HistoryUserShareAssociation( object ): def __init__( self ): @@ -682,6 +688,13 @@ for assoc in self.implicitly_converted_datasets: if not metadata_safe or not assoc.metadata_safe: assoc.clear( purge = purge ) + def get_display_name( self ): + ## Name can be either a string or a unicode object. If string, convert to unicode object assuming 'utf-8' format. + hda_name = self.name + if isinstance(hda_name, str): + hda_name = unicode(hda_name, 'utf-8') + return hda_name + class HistoryDatasetAssociationDisplayAtAuthorization( object ): def __init__( self, hda=None, user=None, site=None ): diff -r f648d6dec544 -r e6324f395d26 lib/galaxy/web/controllers/history.py --- a/lib/galaxy/web/controllers/history.py Mon Oct 05 15:07:20 2009 -0400 +++ b/lib/galaxy/web/controllers/history.py Mon Oct 05 17:38:54 2009 -0400 @@ -18,6 +18,13 @@ class HistoryListGrid( grids.Grid ): # Custom column types + class NameColumn( grids.GridColumn ): + def __init( self, key, link, attach_popup ): + grids.GridColumn.__init__(self, key, link, attach_popup) + + def get_value( self, trans, grid, history ): + return history.get_display_name() + class DatasetsByStateColumn( grids.GridColumn ): def get_value( self, trans, grid, history ): rval = [] @@ -42,7 +49,7 @@ return dict( operation="sharing" ) return None class TagsColumn( grids.GridColumn ): - def __init__(self, col_name, key, filterable): + def __init__( self, col_name, key, filterable ): grids.GridColumn.__init__(self, col_name, key=key, filterable=filterable) # Tags cannot be sorted. self.sortable = False @@ -98,8 +105,8 @@ template='/history/grid.mako' default_sort_key = "-create_time" columns = [ - grids.GridColumn( "Name", key="name", - link=( lambda item: iff( item.deleted, None, dict( operation="switch", id=item.id ) ) ), + NameColumn( "Name", key="name", + link=( lambda history: iff( history.deleted, None, dict( operation="switch", id=history.id ) ) ), attach_popup=True ), DatasetsByStateColumn( "Datasets (by state)", ncells=4 ), TagsColumn( "Tags", key="tags", filterable=True), diff -r f648d6dec544 -r e6324f395d26 templates/dataset/edit_attributes.mako --- a/templates/dataset/edit_attributes.mako Mon Oct 05 15:07:20 2009 -0400 +++ b/templates/dataset/edit_attributes.mako Mon Oct 05 17:38:54 2009 -0400 @@ -35,7 +35,7 @@ Name: </label> <div style="float: left; width: 250px; margin-right: 10px;"> - <input type="text" name="name" value="${data.name}" size="40"/> + <input type="text" name="name" value="${data.get_display_name()}" size="40"/> </div> <div style="clear: both"></div> </div> @@ -155,7 +155,7 @@ %if trans.app.security_agent.can_manage_dataset( user_roles, data.dataset ): <%namespace file="/dataset/security_common.mako" import="render_permission_form" /> - ${render_permission_form( data.dataset, data.name, h.url_for( controller='root', action='edit', id=data.id ), user_roles )} + ${render_permission_form( data.dataset, data.get_display_name(), h.url_for( controller='root', action='edit', id=data.id ), user_roles )} %elif trans.user: <div class="toolForm"> <div class="toolFormTitle">View Permissions</div> diff -r f648d6dec544 -r e6324f395d26 templates/root/history.mako --- a/templates/root/history.mako Mon Oct 05 15:07:20 2009 -0400 +++ b/templates/root/history.mako Mon Oct 05 17:38:54 2009 -0400 @@ -290,7 +290,7 @@ <div id="history-name-area" class="historyLinks" style="color: gray; font-weight: bold;"> <div style="float: right"><a id="history-rename" title="Rename" class="icon-button edit" target="galaxy_main" href="${h.url_for( controller='history', action='rename' )}"></a></div> - <div id="history-name">${history.name}</div> + <div id="history-name">${history.get_display_name()}</div> </div> %if history.deleted: