commit/galaxy-central: jgoecks: Rename APIItem mixin to DictifiableMixin and rename associated attributes and functions as well. Renaming was done because dictification is needed in many places throughout Galaxy, not just the API.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/4f4e01316260/ Changeset: 4f4e01316260 User: jgoecks Date: 2013-08-20 21:43:38 Summary: Rename APIItem mixin to DictifiableMixin and rename associated attributes and functions as well. Renaming was done because dictification is needed in many places throughout Galaxy, not just the API. Affected #: 35 files diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 config/plugins/visualizations/scatterplot/templates/scatterplot.mako --- a/config/plugins/visualizations/scatterplot/templates/scatterplot.mako +++ b/config/plugins/visualizations/scatterplot/templates/scatterplot.mako @@ -41,7 +41,7 @@ <script type="text/javascript"> $(function(){ - var hda = ${h.to_json_string( trans.security.encode_dict_ids( hda.get_api_value() ) )}, + var hda = ${h.to_json_string( trans.security.encode_dict_ids( hda.dictify() ) )}, querySettings = ${h.to_json_string( query_args )}, chartConfig = _.extend( querySettings, { containerSelector : '#chart', diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/model/__init__.py --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -23,7 +23,7 @@ import galaxy.datatypes.registry import galaxy.security.passwords from galaxy.datatypes.metadata import MetadataCollection -from galaxy.model.item_attrs import APIItem, UsesAnnotations +from galaxy.model.item_attrs import DictifiableMixin, UsesAnnotations from galaxy.security import get_permitted_actions from galaxy.util import is_multi_byte, nice_size, Params, restore_text, send_mail from galaxy.util.bunch import Bunch @@ -61,16 +61,16 @@ datatypes_registry = d_registry -class User( object, APIItem ): +class User( object, DictifiableMixin ): use_pbkdf2 = True """ Data for a Galaxy user or admin and relations to their histories, credentials, and roles. """ - # attributes that will be accessed and returned when calling get_api_value( view='collection' ) - api_collection_visible_keys = ( 'id', 'email' ) - # attributes that will be accessed and returned when calling get_api_value( view='element' ) - api_element_visible_keys = ( 'id', 'email', 'username', 'total_disk_usage', 'nice_total_disk_usage' ) + # attributes that will be accessed and returned when calling dictify( view='collection' ) + dict_collection_visible_keys = ( 'id', 'email' ) + # attributes that will be accessed and returned when calling dictify( view='element' ) + dict_element_visible_keys = ( 'id', 'email', 'username', 'total_disk_usage', 'nice_total_disk_usage' ) def __init__( self, email=None, password=None ): self.email = email @@ -157,9 +157,9 @@ return total -class Job( object, APIItem ): - api_collection_visible_keys = [ 'id' ] - api_element_visible_keys = [ 'id' ] +class Job( object, DictifiableMixin ): + dict_collection_visible_keys = [ 'id' ] + dict_element_visible_keys = [ 'id' ] """ A job represents a request to run a tool given input datasets, tool @@ -363,8 +363,8 @@ dataset.blurb = 'deleted' dataset.peek = 'Job deleted' dataset.info = 'Job output deleted by user before job completed' - def get_api_value( self, view='collection' ): - rval = super( Job, self ).get_api_value( view=view ) + def dictify( self, view='collection' ): + rval = super( Job, self ).dictify( view=view ) rval['tool_name'] = self.tool_id param_dict = dict( [ ( p.name, p.value ) for p in self.parameters ] ) rval['params'] = param_dict @@ -649,9 +649,9 @@ else: return False -class Group( object, APIItem ): - api_collection_visible_keys = ( 'id', 'name' ) - api_element_visible_keys = ( 'id', 'name' ) +class Group( object, DictifiableMixin ): + dict_collection_visible_keys = ( 'id', 'name' ) + dict_element_visible_keys = ( 'id', 'name' ) def __init__( self, name = None ): self.name = name @@ -662,10 +662,10 @@ self.user = user self.group = group -class History( object, APIItem, UsesAnnotations ): +class History( object, DictifiableMixin, UsesAnnotations ): - api_collection_visible_keys = ( 'id', 'name', 'published', 'deleted' ) - api_element_visible_keys = ( 'id', 'name', 'published', 'deleted', 'genome_build', 'purged' ) + dict_collection_visible_keys = ( 'id', 'name', 'published', 'deleted' ) + dict_element_visible_keys = ( 'id', 'name', 'published', 'deleted', 'genome_build', 'purged' ) default_name = 'Unnamed history' def __init__( self, id=None, name=None, user=None ): @@ -780,10 +780,10 @@ history_name = unicode(history_name, 'utf-8') return history_name - def get_api_value( self, view='collection', value_mapper = None ): + def dictify( self, view='collection', value_mapper = None ): # Get basic value. - rval = super( History, self ).get_api_value( view=view, value_mapper=value_mapper ) + rval = super( History, self ).dictify( view=view, value_mapper=value_mapper ) # Add tags. tags_str_list = [] @@ -800,14 +800,14 @@ #AKA: set_api_value """ Set object attributes to the values in dictionary new_data limiting - to only those keys in api_element_visible_keys. + to only those keys in dict_element_visible_keys. Returns a dictionary of the keys, values that have been changed. """ # precondition: keys are proper, values are parsed and validated changed = {} # unknown keys are ignored here - for key in [ k for k in new_data.keys() if k in self.api_element_visible_keys ]: + for key in [ k for k in new_data.keys() if k in self.dict_element_visible_keys ]: new_val = new_data[ key ] old_val = self.__getattribute__( key ) if new_val == old_val: @@ -869,9 +869,9 @@ self.group = group self.role = role -class Role( object, APIItem ): - api_collection_visible_keys = ( 'id', 'name' ) - api_element_visible_keys = ( 'id', 'name', 'description', 'type' ) +class Role( object, DictifiableMixin ): + dict_collection_visible_keys = ( 'id', 'name' ) + dict_element_visible_keys = ( 'id', 'name', 'description', 'type' ) private_id = None types = Bunch( PRIVATE = 'private', @@ -886,21 +886,21 @@ self.type = type self.deleted = deleted -class UserQuotaAssociation( object, APIItem ): - api_element_visible_keys = ( 'user', ) +class UserQuotaAssociation( object, DictifiableMixin ): + dict_element_visible_keys = ( 'user', ) def __init__( self, user, quota ): self.user = user self.quota = quota -class GroupQuotaAssociation( object, APIItem ): - api_element_visible_keys = ( 'group', ) +class GroupQuotaAssociation( object, DictifiableMixin ): + dict_element_visible_keys = ( 'group', ) def __init__( self, group, quota ): self.group = group self.quota = quota -class Quota( object, APIItem ): - api_collection_visible_keys = ( 'id', 'name' ) - api_element_visible_keys = ( 'id', 'name', 'description', 'bytes', 'operation', 'display_amount', 'default', 'users', 'groups' ) +class Quota( object, DictifiableMixin ): + dict_collection_visible_keys = ( 'id', 'name' ) + dict_element_visible_keys = ( 'id', 'name', 'description', 'bytes', 'operation', 'display_amount', 'default', 'users', 'groups' ) valid_operations = ( '+', '-', '=' ) def __init__( self, name="", description="", amount=0, operation="=" ): self.name = name @@ -927,8 +927,8 @@ else: return nice_size( self.bytes ) -class DefaultQuotaAssociation( Quota, APIItem ): - api_element_visible_keys = ( 'type', ) +class DefaultQuotaAssociation( Quota, DictifiableMixin ): + dict_element_visible_keys = ( 'type', ) types = Bunch( UNREGISTERED = 'unregistered', REGISTERED = 'registered' @@ -1680,7 +1680,7 @@ rval += child.get_disk_usage( user ) return rval - def get_api_value( self, view='collection' ): + def dictify( self, view='collection' ): """ Return attributes of this HDA that are exposed using the API. """ @@ -1759,10 +1759,10 @@ self.subset = subset self.location = location -class Library( object, APIItem ): +class Library( object, DictifiableMixin ): permitted_actions = get_permitted_actions( filter='LIBRARY' ) - api_collection_visible_keys = ( 'id', 'name' ) - api_element_visible_keys = ( 'id', 'deleted', 'name', 'description', 'synopsis' ) + dict_collection_visible_keys = ( 'id', 'name' ) + dict_element_visible_keys = ( 'id', 'deleted', 'name', 'description', 'synopsis' ) def __init__( self, name=None, description=None, synopsis=None, root_folder=None ): self.name = name or "Unnamed library" self.description = description @@ -1828,8 +1828,8 @@ name = unicode( name, 'utf-8' ) return name -class LibraryFolder( object, APIItem ): - api_element_visible_keys = ( 'id', 'parent_id', 'name', 'description', 'item_count', 'genome_build' ) +class LibraryFolder( object, DictifiableMixin ): + dict_element_visible_keys = ( 'id', 'parent_id', 'name', 'description', 'item_count', 'genome_build' ) def __init__( self, name=None, description=None, item_count=0, order_id=None ): self.name = name or "Unnamed folder" self.description = description @@ -1900,8 +1900,8 @@ if isinstance( name, str ): name = unicode( name, 'utf-8' ) return name - def get_api_value( self, view='collection' ): - rval = super( LibraryFolder, self ).get_api_value( view=view ) + def dictify( self, view='collection' ): + rval = super( LibraryFolder, self ).dictify( view=view ) info_association, inherited = self.get_info_association() if info_association: if inherited: @@ -1966,7 +1966,7 @@ name = property( get_name, set_name ) def display_name( self ): self.library_dataset_dataset_association.display_name() - def get_api_value( self, view='collection' ): + def dictify( self, view='collection' ): # Since this class is a proxy to rather complex attributes we want to # display in other objects, we can't use the simpler method used by # other model classes. @@ -2096,7 +2096,7 @@ if restrict: return None, inherited return self.library_dataset.folder.get_info_association( inherited=True ) - def get_api_value( self, view='collection' ): + def dictify( self, view='collection' ): # Since this class is a proxy to rather complex attributes we want to # display in other objects, we can't use the simpler method used by # other model classes. @@ -2323,9 +2323,9 @@ self.id = None self.user = None -class StoredWorkflow( object, APIItem): - api_collection_visible_keys = ( 'id', 'name', 'published' ) - api_element_visible_keys = ( 'id', 'name', 'published' ) +class StoredWorkflow( object, DictifiableMixin): + dict_collection_visible_keys = ( 'id', 'name', 'published' ) + dict_element_visible_keys = ( 'id', 'name', 'published' ) def __init__( self ): self.id = None self.user = None @@ -2341,8 +2341,8 @@ new_swta.user = target_user self.tags.append(new_swta) - def get_api_value( self, view='collection', value_mapper = None ): - rval = APIItem.get_api_value(self, view=view, value_mapper = value_mapper) + def dictify( self, view='collection', value_mapper = None ): + rval = DictifiableMixin.dictify(self, view=view, value_mapper = value_mapper) tags_str_list = [] for tag in self.tags: tag_str = tag.user_tname @@ -2434,7 +2434,7 @@ return os.path.abspath( os.path.join( path, "metadata_%d.dat" % self.id ) ) -class FormDefinition( object, APIItem ): +class FormDefinition( object, DictifiableMixin ): # The following form_builder classes are supported by the FormDefinition class. supported_field_types = [ AddressField, CheckboxField, PasswordField, SelectField, TextArea, TextField, WorkflowField, WorkflowMappingField, HistoryField ] types = Bunch( REQUEST = 'Sequencing Request Form', @@ -2443,8 +2443,8 @@ RUN_DETAILS_TEMPLATE = 'Sample run details template', LIBRARY_INFO_TEMPLATE = 'Library information template', USER_INFO = 'User Information' ) - api_collection_visible_keys = ( 'id', 'name' ) - api_element_visible_keys = ( 'id', 'name', 'desc', 'form_definition_current_id', 'fields', 'layout' ) + dict_collection_visible_keys = ( 'id', 'name' ) + dict_element_visible_keys = ( 'id', 'name', 'desc', 'form_definition_current_id', 'fields', 'layout' ) def __init__( self, name=None, desc=None, fields=[], form_definition_current=None, form_type=None, layout=None ): self.name = name self.desc = desc @@ -2562,12 +2562,12 @@ self.form_definition = form_def self.content = content -class Request( object, APIItem ): +class Request( object, DictifiableMixin ): states = Bunch( NEW = 'New', SUBMITTED = 'In Progress', REJECTED = 'Rejected', COMPLETE = 'Complete' ) - api_collection_visible_keys = ( 'id', 'name', 'state' ) + dict_collection_visible_keys = ( 'id', 'name', 'state' ) def __init__( self, name=None, desc=None, request_type=None, user=None, form_values=None, notification=None ): self.name = name self.desc = desc @@ -2753,9 +2753,9 @@ def populate_actions( self, trans, item, param_dict=None ): return self.get_external_service_type( trans ).actions.populate( self, item, param_dict=param_dict ) -class RequestType( object, APIItem ): - api_collection_visible_keys = ( 'id', 'name', 'desc' ) - api_element_visible_keys = ( 'id', 'name', 'desc', 'request_form_id', 'sample_form_id' ) +class RequestType( object, DictifiableMixin ): + dict_collection_visible_keys = ( 'id', 'name', 'desc' ) + dict_element_visible_keys = ( 'id', 'name', 'desc', 'request_form_id', 'sample_form_id' ) rename_dataset_options = Bunch( NO = 'Do not rename', SAMPLE_NAME = 'Preprend sample name', EXPERIMENT_NAME = 'Prepend experiment name', @@ -2839,12 +2839,12 @@ self.request_type = request_type self.role = role -class Sample( object, APIItem ): +class Sample( object, DictifiableMixin ): # The following form_builder classes are supported by the Sample class. supported_field_types = [ CheckboxField, SelectField, TextField, WorkflowField, WorkflowMappingField, HistoryField ] bulk_operations = Bunch( CHANGE_STATE = 'Change state', SELECT_LIBRARY = 'Select data library and folder' ) - api_collection_visible_keys = ( 'id', 'name' ) + dict_collection_visible_keys = ( 'id', 'name' ) def __init__(self, name=None, desc=None, request=None, form_values=None, bar_code=None, library=None, folder=None, workflow=None, history=None): self.name = name self.desc = desc @@ -3169,9 +3169,9 @@ def __str__ ( self ): return "Tag(id=%s, type=%i, parent_id=%s, name=%s)" % ( self.id, self.type, self.parent_id, self.name ) -class ItemTagAssociation ( object, APIItem ): - api_collection_visible_keys = ( 'id', 'user_tname', 'user_value' ) - api_element_visible_keys = api_collection_visible_keys +class ItemTagAssociation ( object, DictifiableMixin ): + dict_collection_visible_keys = ( 'id', 'user_tname', 'user_value' ) + dict_element_visible_keys = dict_collection_visible_keys def __init__( self, id=None, user=None, item_id=None, tag_id=None, user_tname=None, value=None ): self.id = id @@ -3307,9 +3307,9 @@ pass class ToolShedRepository( object ): - api_collection_visible_keys = ( 'id', 'tool_shed', 'name', 'owner', 'installed_changeset_revision', 'changeset_revision', 'ctx_rev', 'includes_datatypes', + dict_collection_visible_keys = ( 'id', 'tool_shed', 'name', 'owner', 'installed_changeset_revision', 'changeset_revision', 'ctx_rev', 'includes_datatypes', 'update_available', 'deleted', 'uninstalled', 'dist_to_shed', 'status', 'error_message' ) - api_element_visible_keys = ( 'id', 'tool_shed', 'name', 'owner', 'installed_changeset_revision', 'changeset_revision', 'ctx_rev', 'includes_datatypes', + dict_element_visible_keys = ( 'id', 'tool_shed', 'name', 'owner', 'installed_changeset_revision', 'changeset_revision', 'ctx_rev', 'includes_datatypes', 'update_available', 'deleted', 'uninstalled', 'dist_to_shed', 'status', 'error_message' ) installation_status = Bunch( NEW='New', CLONING='Cloning', @@ -3347,7 +3347,7 @@ self.status = status self.error_message = error_message def as_dict( self, value_mapper=None ): - return self.get_api_value( view='element', value_mapper=value_mapper ) + return self.dictify( view='element', value_mapper=value_mapper ) def repo_files_directory( self, app ): repo_path = self.repo_path( app ) if repo_path: @@ -3435,7 +3435,7 @@ if self.shed_config_filename == shed_tool_conf_dict[ 'config_filename' ]: return shed_tool_conf_dict return default - def get_api_value( self, view='collection', value_mapper=None ): + def dictify( self, view='collection', value_mapper=None ): if value_mapper is None: value_mapper = {} rval = {} @@ -3699,8 +3699,8 @@ self.tool_shed_repository.name, self.tool_shed_repository.installed_changeset_revision ) -class ToolVersion( object, APIItem ): - api_element_visible_keys = ( 'id', 'tool_shed_repository' ) +class ToolVersion( object, DictifiableMixin ): + dict_element_visible_keys = ( 'id', 'tool_shed_repository' ) def __init__( self, id=None, create_time=None, tool_id=None, tool_shed_repository=None ): self.id = id self.create_time = create_time @@ -3757,8 +3757,8 @@ return version_ids return [ tool_version.tool_id for tool_version in self.get_versions( app ) ] - def get_api_value( self, view='element' ): - rval = APIItem.get_api_value(self, view) + def dictify( self, view='element' ): + rval = DictifiableMixin.dictify(self, view) rval['tool_name'] = self.tool_id for a in self.parent_tool_association: rval['parent_tool_id'] = a.parent_id diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/model/item_attrs.py --- a/lib/galaxy/model/item_attrs.py +++ b/lib/galaxy/model/item_attrs.py @@ -158,10 +158,12 @@ class_name = '%sAnnotationAssociation' % item.__class__.__name__ return getattr( galaxy.model, class_name, None ) -class APIItem: - """ Mixin for api representation. """ +class DictifiableMixin: + """ Mixin that enables objects to be converted to dictionaries. This is useful + when for sharing objects across boundaries, such as the API, tool scripts, + and JavaScript code. """ - def get_api_value( self, view='collection', value_mapper=None ): + def dictify( self, view='collection', value_mapper=None ): """ Return item dictionary. """ @@ -174,9 +176,9 @@ Recursive helper function to get item values. """ # FIXME: why use exception here? Why not look for key in value_mapper - # first and then default to get_api_value? + # first and then default to dictify? try: - return item.get_api_value( view=view, value_mapper=value_mapper ) + return item.dictify( view=view, value_mapper=value_mapper ) except: if key in value_mapper: return value_mapper.get( key )( item ) @@ -189,7 +191,7 @@ # Fill item dict with visible keys. try: - visible_keys = self.__getattribute__( 'api_' + view + '_visible_keys' ) + visible_keys = self.__getattribute__( 'dict_' + view + '_visible_keys' ) except AttributeError: raise Exception( 'Unknown API view: %s' % view ) for key in visible_keys: diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/model/search.py --- a/lib/galaxy/model/search.py +++ b/lib/galaxy/model/search.py @@ -560,7 +560,7 @@ return self.view.get_results(True) def item_to_api_value(self, item): - r = item.get_api_value( view='element' ) + r = item.dictify( view='element' ) if self.query.field_list.count("*"): return r o = {} diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/web/base/controller.py --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -422,7 +422,7 @@ def get_history_dict( self, trans, history, hda_dictionaries=None ): """Returns history data in the form of a dictionary. """ - history_dict = history.get_api_value( view='element', value_mapper={ 'id':trans.security.encode_id }) + history_dict = history.dictify( view='element', value_mapper={ 'id':trans.security.encode_id }) history_dict[ 'nice_size' ] = history.get_disk_size( nice_size=True ) history_dict[ 'annotation' ] = history.get_item_annotation_str( trans.sa_session, trans.user, history ) @@ -583,7 +583,7 @@ """ #precondition: the user's access to this hda has already been checked #TODO:?? postcondition: all ids are encoded (is this really what we want at this level?) - hda_dict = hda.get_api_value( view='element' ) + hda_dict = hda.dictify( view='element' ) hda_dict[ 'api_type' ] = "file" # Add additional attributes that depend on trans can hence must be added here rather than at the model level. @@ -594,7 +594,7 @@ # ---- return here if deleted AND purged OR can't access purged = ( hda.purged or hda.dataset.purged ) if ( hda.deleted and purged ): - #TODO: get_api_value should really go AFTER this - only summary data + #TODO: dictify should really go AFTER this - only summary data return trans.security.encode_dict_ids( hda_dict ) if trans.user_is_admin() or trans.app.config.expose_dataset_path: @@ -911,7 +911,7 @@ return query return query.all() - #TODO: move into model (get_api_value) + #TODO: move into model (dictify) def get_visualization_summary_dict( self, visualization ): """ Return a set of summary attributes for a visualization in dictionary form. @@ -1132,7 +1132,7 @@ source='data' ) return { "track_type": dataset.datatype.track_type, - "dataset": trans.security.encode_dict_ids( dataset.get_api_value() ), + "dataset": trans.security.encode_dict_ids( dataset.dictify() ), "name": track_dict['name'], "prefs": prefs, "mode": track_dict.get( 'mode', 'Auto' ), @@ -1212,7 +1212,7 @@ return { "track_type": dataset.datatype.track_type, "name": dataset.name, - "dataset": trans.security.encode_dict_ids( dataset.get_api_value() ), + "dataset": trans.security.encode_dict_ids( dataset.dictify() ), "prefs": {}, "filters": { 'filters' : track_data_provider.get_filters() }, "tool": get_tool_def( trans, dataset ), diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/webapps/galaxy/api/datasets.py --- a/lib/galaxy/webapps/galaxy/api/datasets.py +++ b/lib/galaxy/webapps/galaxy/api/datasets.py @@ -60,7 +60,7 @@ rval[ 'display_types' ] = self.get_old_display_applications( trans, dataset ) rval[ 'display_apps' ] = self.get_display_apps( trans, dataset ) else: - rval = dataset.get_api_value() + rval = dataset.dictify() except Exception, e: rval = "Error in dataset API at listing contents: " + str( e ) diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/webapps/galaxy/api/folders.py --- a/lib/galaxy/webapps/galaxy/api/folders.py +++ b/lib/galaxy/webapps/galaxy/api/folders.py @@ -35,7 +35,7 @@ # check_ownership=false since we are only displaying it. content = self.get_library_folder( trans, id, check_ownership=False, check_accessible=True ) - return self.encode_all_ids( trans, content.get_api_value( view='element' ) ) + return self.encode_all_ids( trans, content.dictify( view='element' ) ) @web.expose_api def create( self, trans, payload, **kwd ): diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/webapps/galaxy/api/forms.py --- a/lib/galaxy/webapps/galaxy/api/forms.py +++ b/lib/galaxy/webapps/galaxy/api/forms.py @@ -23,7 +23,7 @@ query = trans.sa_session.query( trans.app.model.FormDefinition )#.filter( trans.app.model.FormDefinition.table.c.deleted == False ) rval = [] for form_definition in query: - item = form_definition.get_api_value( value_mapper={ 'id': trans.security.encode_id, 'form_definition_current_id': trans.security.encode_id } ) + item = form_definition.dictify( value_mapper={ 'id': trans.security.encode_id, 'form_definition_current_id': trans.security.encode_id } ) item['url'] = url_for( 'form', id=trans.security.encode_id( form_definition.id ) ) rval.append( item ) return rval @@ -47,7 +47,7 @@ if not form_definition or not trans.user_is_admin(): trans.response.status = 400 return "Invalid form definition id ( %s ) specified." % str( form_definition_id ) - item = form_definition.get_api_value( view='element', value_mapper={ 'id': trans.security.encode_id, 'form_definition_current_id': trans.security.encode_id } ) + item = form_definition.dictify( view='element', value_mapper={ 'id': trans.security.encode_id, 'form_definition_current_id': trans.security.encode_id } ) item['url'] = url_for( 'form', id=form_definition_id ) return item @@ -69,6 +69,6 @@ trans.sa_session.add( form_definition ) trans.sa_session.flush() encoded_id = trans.security.encode_id( form_definition.id ) - item = form_definition.get_api_value( view='element', value_mapper={ 'id': trans.security.encode_id, 'form_definition_current_id': trans.security.encode_id } ) + item = form_definition.dictify( view='element', value_mapper={ 'id': trans.security.encode_id, 'form_definition_current_id': trans.security.encode_id } ) item['url'] = url_for( 'form', id=encoded_id ) return [ item ] diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/webapps/galaxy/api/groups.py --- a/lib/galaxy/webapps/galaxy/api/groups.py +++ b/lib/galaxy/webapps/galaxy/api/groups.py @@ -21,7 +21,7 @@ rval = [] for group in trans.sa_session.query( trans.app.model.Group ).filter( trans.app.model.Group.table.c.deleted == False ): if trans.user_is_admin(): - item = group.get_api_value( value_mapper={ 'id': trans.security.encode_id } ) + item = group.dictify( value_mapper={ 'id': trans.security.encode_id } ) encoded_id = trans.security.encode_id( group.id ) item['url'] = url_for( 'group', id=encoded_id ) rval.append( item ) @@ -65,7 +65,7 @@ """ trans.sa_session.flush() encoded_id = trans.security.encode_id( group.id ) - item = group.get_api_value( view='element', value_mapper={ 'id': trans.security.encode_id } ) + item = group.dictify( view='element', value_mapper={ 'id': trans.security.encode_id } ) item['url'] = url_for( 'group', id=encoded_id ) return [ item ] @@ -89,7 +89,7 @@ if not group: trans.response.status = 400 return "Invalid group id ( %s ) specified." % str( group_id ) - item = group.get_api_value( view='element', value_mapper={ 'id': trans.security.encode_id } ) + item = group.dictify( view='element', value_mapper={ 'id': trans.security.encode_id } ) item['url'] = url_for( 'group', id=group_id ) item['users_url'] = url_for( 'group_users', group_id=group_id ) item['roles_url'] = url_for( 'group_roles', group_id=group_id ) diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/webapps/galaxy/api/histories.py --- a/lib/galaxy/webapps/galaxy/api/histories.py +++ b/lib/galaxy/webapps/galaxy/api/histories.py @@ -46,14 +46,14 @@ .order_by( desc( trans.app.model.History.table.c.update_time ) ) .all() ) for history in query: - item = history.get_api_value(value_mapper={'id':trans.security.encode_id}) + item = history.dictify(value_mapper={'id':trans.security.encode_id}) item['url'] = url_for( 'history', id=trans.security.encode_id( history.id ) ) rval.append( item ) elif trans.galaxy_session.current_history: #No user, this must be session authentication with an anonymous user. history = trans.galaxy_session.current_history - item = history.get_api_value(value_mapper={'id':trans.security.encode_id}) + item = history.dictify(value_mapper={'id':trans.security.encode_id}) item['url'] = url_for( 'history', id=trans.security.encode_id( history.id ) ) rval.append(item) @@ -139,7 +139,7 @@ trans.sa_session.add( new_history ) trans.sa_session.flush() - item = new_history.get_api_value(view='element', value_mapper={'id':trans.security.encode_id}) + item = new_history.dictify(view='element', value_mapper={'id':trans.security.encode_id}) item['url'] = url_for( 'history', id=item['id'] ) #TODO: copy own history @@ -254,7 +254,7 @@ :param id: the encoded id of the history to undelete :type payload: dict :param payload: a dictionary containing any or all the - fields in :func:`galaxy.model.History.get_api_value` and/or the following: + fields in :func:`galaxy.model.History.dictify` and/or the following: * annotation: an annotation for the history diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/webapps/galaxy/api/history_contents.py --- a/lib/galaxy/webapps/galaxy/api/history_contents.py +++ b/lib/galaxy/webapps/galaxy/api/history_contents.py @@ -190,7 +190,7 @@ hda = ld.library_dataset_dataset_association.to_history_dataset_association( history, add_to_history=True ) trans.sa_session.flush() - return hda.get_api_value() + return hda.dictify() else: # TODO: implement other "upload" methods here. @@ -210,7 +210,7 @@ :param id: the encoded id of the history to undelete :type payload: dict :param payload: a dictionary containing any or all the - fields in :func:`galaxy.model.HistoryDatasetAssociation.get_api_value` + fields in :func:`galaxy.model.HistoryDatasetAssociation.dictify` and/or the following: * annotation: an annotation for the HDA diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/webapps/galaxy/api/item_tags.py --- a/lib/galaxy/webapps/galaxy/api/item_tags.py +++ b/lib/galaxy/webapps/galaxy/api/item_tags.py @@ -49,7 +49,7 @@ return 'OK' def _api_value( self, tag, trans, view='element' ): - return tag.get_api_value( view=view, value_mapper={ 'id': trans.security.encode_id } ) + return tag.dictify( view=view, value_mapper={ 'id': trans.security.encode_id } ) class HistoryContentTagsController( BaseItemTagsController ): controller_name = "history_content_tags" diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/webapps/galaxy/api/libraries.py --- a/lib/galaxy/webapps/galaxy/api/libraries.py +++ b/lib/galaxy/webapps/galaxy/api/libraries.py @@ -26,7 +26,7 @@ :rtype: list :returns: list of dictionaries containing library information - .. seealso:: :attr:`galaxy.model.Library.api_collection_visible_keys` + .. seealso:: :attr:`galaxy.model.Library.dict_collection_visible_keys` """ log.debug( "LibrariesController.index: enter" ) query = trans.sa_session.query( trans.app.model.Library ) @@ -49,7 +49,7 @@ trans.model.Library.table.c.id.in_( accessible_restricted_library_ids ) ) ) rval = [] for library in query: - item = library.get_api_value() + item = library.dictify() item['url'] = url_for( route, id=trans.security.encode_id( library.id ) ) item['id'] = trans.security.encode_id( item['id'] ) rval.append( item ) @@ -71,7 +71,7 @@ :rtype: dictionary :returns: detailed library information - .. seealso:: :attr:`galaxy.model.Library.api_element_visible_keys` + .. seealso:: :attr:`galaxy.model.Library.dict_element_visible_keys` """ log.debug( "LibraryContentsController.show: enter" ) library_id = id @@ -87,7 +87,7 @@ library = None if not library or not ( trans.user_is_admin() or trans.app.security_agent.can_access_library( trans.get_current_user_roles(), library ) ): raise HTTPBadRequest( detail='Invalid library id ( %s ) specified.' % id ) - item = library.get_api_value( view='element' ) + item = library.dictify( view='element' ) #item['contents_url'] = url_for( 'contents', library_id=library_id ) item['contents_url'] = url_for( 'library_contents', library_id=library_id ) return item @@ -145,7 +145,7 @@ :rtype: dictionary :returns: detailed library information - .. seealso:: :attr:`galaxy.model.Library.api_element_visible_keys` + .. seealso:: :attr:`galaxy.model.Library.dict_element_visible_keys` """ if not trans.user_is_admin(): raise HTTPForbidden( detail='You are not authorized to delete libraries.' ) @@ -162,4 +162,4 @@ library.deleted = True trans.sa_session.add( library ) trans.sa_session.flush() - return library.get_api_value( view='element', value_mapper={ 'id' : trans.security.encode_id } ) + return library.dictify( view='element', value_mapper={ 'id' : trans.security.encode_id } ) diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/webapps/galaxy/api/library_contents.py --- a/lib/galaxy/webapps/galaxy/api/library_contents.py +++ b/lib/galaxy/webapps/galaxy/api/library_contents.py @@ -105,15 +105,15 @@ :rtype: dict :returns: detailed library item information .. seealso:: - :func:`galaxy.model.LibraryDataset.get_api_value` and - :attr:`galaxy.model.LibraryFolder.api_element_visible_keys` + :func:`galaxy.model.LibraryDataset.dictify` and + :attr:`galaxy.model.LibraryFolder.dict_element_visible_keys` """ class_name, content_id = self.__decode_library_content_id( trans, id ) if class_name == 'LibraryFolder': content = self.get_library_folder( trans, content_id, check_ownership=False, check_accessible=True ) else: content = self.get_library_dataset( trans, content_id, check_ownership=False, check_accessible=True ) - return self.encode_all_ids( trans, content.get_api_value( view='element' ) ) + return self.encode_all_ids( trans, content.dictify( view='element' ) ) @web.expose_api def create( self, trans, library_id, payload, **kwd ): @@ -266,7 +266,7 @@ return { 'error' : 'user has no permission to add to library folder (%s)' %( folder_id ) } ldda = self.copy_hda_to_library_folder( trans, hda, folder, ldda_message=ldda_message ) - ldda_dict = ldda.get_api_value() + ldda_dict = ldda.dictify() rval = trans.security.encode_dict_ids( ldda_dict ) except Exception, exc: diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/webapps/galaxy/api/permissions.py --- a/lib/galaxy/webapps/galaxy/api/permissions.py +++ b/lib/galaxy/webapps/galaxy/api/permissions.py @@ -47,6 +47,6 @@ trans.app.security_agent.copy_library_permissions( trans, library, library.root_folder ) message = "Permissions updated for library '%s'." % library.name - item = library.get_api_value( view='element' ) + item = library.dictify( view='element' ) return item diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/webapps/galaxy/api/quotas.py --- a/lib/galaxy/webapps/galaxy/api/quotas.py +++ b/lib/galaxy/webapps/galaxy/api/quotas.py @@ -34,7 +34,7 @@ route = 'quota' query = query.filter( trans.app.model.Quota.table.c.deleted == False ) for quota in query: - item = quota.get_api_value( value_mapper={ 'id': trans.security.encode_id } ) + item = quota.dictify( value_mapper={ 'id': trans.security.encode_id } ) encoded_id = trans.security.encode_id( quota.id ) item['url'] = url_for( route, id=encoded_id ) rval.append( item ) @@ -49,7 +49,7 @@ Displays information about a quota. """ quota = self.get_quota( trans, id, deleted=util.string_as_bool( deleted ) ) - return quota.get_api_value( view='element', value_mapper={ 'id': trans.security.encode_id } ) + return quota.dictify( view='element', value_mapper={ 'id': trans.security.encode_id } ) @web.expose_api @web.require_admin @@ -67,7 +67,7 @@ quota, message = self._create_quota( params ) except ActionInputError, e: raise HTTPBadRequest( detail=str( e ) ) - item = quota.get_api_value( value_mapper={ 'id': trans.security.encode_id } ) + item = quota.dictify( value_mapper={ 'id': trans.security.encode_id } ) item['url'] = url_for( 'quota', id=trans.security.encode_id( quota.id ) ) item['message'] = message return item diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/webapps/galaxy/api/request_types.py --- a/lib/galaxy/webapps/galaxy/api/request_types.py +++ b/lib/galaxy/webapps/galaxy/api/request_types.py @@ -19,7 +19,7 @@ """ rval = [] for request_type in trans.app.security_agent.get_accessible_request_types( trans, trans.user ): - item = request_type.get_api_value( value_mapper={ 'id': trans.security.encode_id, 'request_form_id': trans.security.encode_id, 'sample_form_id': trans.security.encode_id } ) + item = request_type.dictify( value_mapper={ 'id': trans.security.encode_id, 'request_form_id': trans.security.encode_id, 'sample_form_id': trans.security.encode_id } ) encoded_id = trans.security.encode_id( request_type.id ) item['url'] = url_for( 'request_type', id=encoded_id ) rval.append( item ) @@ -47,7 +47,7 @@ if not trans.app.security_agent.can_access_request_type( trans.user.all_roles(), request_type ): trans.response.status = 400 return "No permission to access request_type ( %s )." % str( request_type_id ) - item = request_type.get_api_value( view='element', value_mapper={ 'id': trans.security.encode_id, 'request_form_id': trans.security.encode_id, 'sample_form_id': trans.security.encode_id } ) + item = request_type.dictify( view='element', value_mapper={ 'id': trans.security.encode_id, 'request_form_id': trans.security.encode_id, 'sample_form_id': trans.security.encode_id } ) item['url'] = url_for( 'request_type', id=request_type_id ) return item @@ -97,6 +97,6 @@ trans.sa_session.add( request_type ) trans.sa_session.flush() encoded_id = trans.security.encode_id( request_type.id ) - item = request_type.get_api_value( view='element', value_mapper={ 'id': trans.security.encode_id, 'request_form_id': trans.security.encode_id, 'sample_form_id': trans.security.encode_id } ) + item = request_type.dictify( view='element', value_mapper={ 'id': trans.security.encode_id, 'request_form_id': trans.security.encode_id, 'sample_form_id': trans.security.encode_id } ) item['url'] = url_for( 'request_type', id=encoded_id ) return [ item ] diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/webapps/galaxy/api/requests.py --- a/lib/galaxy/webapps/galaxy/api/requests.py +++ b/lib/galaxy/webapps/galaxy/api/requests.py @@ -30,7 +30,7 @@ .all() rval = [] for request in query: - item = request.get_api_value() + item = request.dictify() item['url'] = url_for( 'requests', id=trans.security.encode_id( request.id ) ) item['id'] = trans.security.encode_id( item['id'] ) if trans.user_is_admin(): @@ -55,7 +55,7 @@ if not request or not ( trans.user_is_admin() or request.user.id == trans.user.id ): trans.response.status = 400 return "Invalid request id ( %s ) specified." % str( request_id ) - item = request.get_api_value() + item = request.dictify() item['url'] = url_for( 'requests', id=trans.security.encode_id( request.id ) ) item['id'] = trans.security.encode_id( item['id'] ) item['user'] = request.user.email diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/webapps/galaxy/api/roles.py --- a/lib/galaxy/webapps/galaxy/api/roles.py +++ b/lib/galaxy/webapps/galaxy/api/roles.py @@ -18,7 +18,7 @@ rval = [] for role in trans.sa_session.query( trans.app.model.Role ).filter( trans.app.model.Role.table.c.deleted == False ): if trans.user_is_admin() or trans.app.security_agent.ok_to_display( trans.user, role ): - item = role.get_api_value( value_mapper={ 'id': trans.security.encode_id } ) + item = role.dictify( value_mapper={ 'id': trans.security.encode_id } ) encoded_id = trans.security.encode_id( role.id ) item['url'] = url_for( 'role', id=encoded_id ) rval.append( item ) @@ -43,7 +43,7 @@ if not role or not (trans.user_is_admin() or trans.app.security_agent.ok_to_display( trans.user, role )): trans.response.status = 400 return "Invalid role id ( %s ) specified." % str( role_id ) - item = role.get_api_value( view='element', value_mapper={ 'id': trans.security.encode_id } ) + item = role.dictify( view='element', value_mapper={ 'id': trans.security.encode_id } ) item['url'] = url_for( 'role', id=role_id ) return item @@ -81,6 +81,6 @@ trans.app.security_agent.associate_group_role( group, role ) trans.sa_session.flush() encoded_id = trans.security.encode_id( role.id ) - item = role.get_api_value( view='element', value_mapper={ 'id': trans.security.encode_id } ) + item = role.dictify( view='element', value_mapper={ 'id': trans.security.encode_id } ) item['url'] = url_for( 'role', id=encoded_id ) return [ item ] diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/webapps/galaxy/api/samples.py --- a/lib/galaxy/webapps/galaxy/api/samples.py +++ b/lib/galaxy/webapps/galaxy/api/samples.py @@ -35,7 +35,7 @@ return "Invalid request id ( %s ) specified." % str( request_id ) rval = [] for sample in request.samples: - item = sample.get_api_value() + item = sample.dictify() item['url'] = url_for( 'samples', request_id=trans.security.encode_id( request_id ), id=trans.security.encode_id( sample.id ) ) diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/webapps/galaxy/api/tool_shed_repositories.py --- a/lib/galaxy/webapps/galaxy/api/tool_shed_repositories.py +++ b/lib/galaxy/webapps/galaxy/api/tool_shed_repositories.py @@ -45,7 +45,7 @@ .order_by( trans.app.model.ToolShedRepository.table.c.name ) \ .all() for tool_shed_repository in query: - tool_shed_repository_dict = tool_shed_repository.get_api_value( value_mapper=default_tool_shed_repository_value_mapper( trans, tool_shed_repository ) ) + tool_shed_repository_dict = tool_shed_repository.dictify( value_mapper=default_tool_shed_repository_value_mapper( trans, tool_shed_repository ) ) tool_shed_repository_dict[ 'url' ] = web.url_for( controller='tool_shed_repositories', action='show', id=trans.security.encode_id( tool_shed_repository.id ) ) @@ -402,7 +402,7 @@ repair_dict = repository_util.repair_tool_shed_repository( trans, repository, encoding_util.tool_shed_encode( repo_info_dict ) ) - repository_dict = repository.get_api_value( value_mapper=default_tool_shed_repository_value_mapper( trans, repository ) ) + repository_dict = repository.dictify( value_mapper=default_tool_shed_repository_value_mapper( trans, repository ) ) repository_dict[ 'url' ] = web.url_for( controller='tool_shed_repositories', action='show', id=trans.security.encode_id( repository.id ) ) diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/webapps/galaxy/api/tools.py --- a/lib/galaxy/webapps/galaxy/api/tools.py +++ b/lib/galaxy/webapps/galaxy/api/tools.py @@ -106,7 +106,7 @@ outputs = rval[ "outputs" ] #TODO:?? poss. only return ids? for output in output_datasets: - output_dict = output.get_api_value() + output_dict = output.dictify() outputs.append( trans.security.encode_dict_ids( output_dict ) ) return rval @@ -412,7 +412,7 @@ if joda.name == output_name: output_dataset = joda.dataset - dataset_dict = output_dataset.get_api_value() + dataset_dict = output_dataset.dictify() dataset_dict[ 'id' ] = trans.security.encode_id( dataset_dict[ 'id' ] ) dataset_dict[ 'track_config' ] = self.get_new_track_config( trans, output_dataset ); return dataset_dict diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/webapps/galaxy/api/users.py --- a/lib/galaxy/webapps/galaxy/api/users.py +++ b/lib/galaxy/webapps/galaxy/api/users.py @@ -33,13 +33,13 @@ query = query.filter( trans.app.model.User.table.c.deleted == False ) # special case: user can see only their own user if not trans.user_is_admin(): - item = trans.user.get_api_value( value_mapper={ 'id': trans.security.encode_id } ) + item = trans.user.dictify( value_mapper={ 'id': trans.security.encode_id } ) item['url'] = url_for( route, id=item['id'] ) item['quota_percent'] = trans.app.quota_agent.get_percent( trans=trans ) return [item] for user in query: - item = user.get_api_value( value_mapper={ 'id': trans.security.encode_id } ) + item = user.dictify( value_mapper={ 'id': trans.security.encode_id } ) #TODO: move into api_values item['quota_percent'] = trans.app.quota_agent.get_percent( trans=trans ) item['url'] = url_for( route, id=item['id'] ) @@ -77,7 +77,7 @@ raise else: raise HTTPBadRequest( detail='Invalid user id ( %s ) specified' % id ) - item = user.get_api_value( view='element', value_mapper={ 'id': trans.security.encode_id, + item = user.dictify( view='element', value_mapper={ 'id': trans.security.encode_id, 'total_disk_usage': float } ) #TODO: move into api_values (needs trans, tho - can we do that with api_keys/@property??) #TODO: works with other users (from admin)?? @@ -94,7 +94,7 @@ raise HTTPNotImplemented( detail='User creation is not allowed in this Galaxy instance' ) if trans.app.config.use_remote_user and trans.user_is_admin(): user = trans.get_or_create_remote_user(remote_user_email=payload['remote_user_email']) - item = user.get_api_value( view='element', value_mapper={ 'id': trans.security.encode_id, + item = user.dictify( view='element', value_mapper={ 'id': trans.security.encode_id, 'total_disk_usage': float } ) else: raise HTTPNotImplemented() diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/webapps/galaxy/api/visualizations.py --- a/lib/galaxy/webapps/galaxy/api/visualizations.py +++ b/lib/galaxy/webapps/galaxy/api/visualizations.py @@ -212,7 +212,7 @@ # this allows PUT'ing an entire model back to the server without attribute errors on uneditable attrs valid_but_uneditable_keys = ( 'id', 'model_class' - #TODO: fill out when we create get_api_value, get_dict, whatevs + #TODO: fill out when we create dictify, get_dict, whatevs ) #TODO: deleted #TODO: importable diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/webapps/galaxy/api/workflows.py --- a/lib/galaxy/webapps/galaxy/api/workflows.py +++ b/lib/galaxy/webapps/galaxy/api/workflows.py @@ -31,7 +31,7 @@ for wf in trans.sa_session.query(trans.app.model.StoredWorkflow).filter_by( user=trans.user, deleted=False).order_by( desc(trans.app.model.StoredWorkflow.table.c.update_time)).all(): - item = wf.get_api_value(value_mapper={'id':trans.security.encode_id}) + item = wf.dictify(value_mapper={'id':trans.security.encode_id}) encoded_id = trans.security.encode_id(wf.id) item['url'] = url_for('workflow', id=encoded_id) rval.append(item) @@ -39,7 +39,7 @@ user=trans.user ).join( 'stored_workflow' ).filter( trans.app.model.StoredWorkflow.deleted == False ).order_by( desc( trans.app.model.StoredWorkflow.update_time ) ).all(): - item = wf_sa.stored_workflow.get_api_value(value_mapper={'id':trans.security.encode_id}) + item = wf_sa.stored_workflow.dictify(value_mapper={'id':trans.security.encode_id}) encoded_id = trans.security.encode_id(wf_sa.stored_workflow.id) item['url'] = url_for('workflow', id=encoded_id) rval.append(item) @@ -67,7 +67,7 @@ except: trans.response.status = 400 return "That workflow does not exist." - item = stored_workflow.get_api_value(view='element', value_mapper={'id':trans.security.encode_id}) + item = stored_workflow.dictify(view='element', value_mapper={'id':trans.security.encode_id}) item['url'] = url_for('workflow', id=workflow_id) latest_workflow = stored_workflow.latest_workflow inputs = {} @@ -329,7 +329,7 @@ # return list rval= []; - item = workflow.get_api_value(value_mapper={'id':trans.security.encode_id}) + item = workflow.dictify(value_mapper={'id':trans.security.encode_id}) item['url'] = url_for('workflow', id=encoded_id) rval.append(item); diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/webapps/galaxy/controllers/visualization.py --- a/lib/galaxy/webapps/galaxy/controllers/visualization.py +++ b/lib/galaxy/webapps/galaxy/controllers/visualization.py @@ -875,7 +875,7 @@ # Add tool, dataset attributes to config based on id. tool = trans.app.toolbox.get_tool( viz_config[ 'tool_id' ] ) viz_config[ 'tool' ] = tool.to_dict( trans, for_display=True ) - viz_config[ 'dataset' ] = dataset.get_api_value() + viz_config[ 'dataset' ] = dataset.dictify() return trans.fill_template_mako( "visualization/sweepster.mako", config=viz_config ) diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/webapps/tool_shed/api/repositories.py --- a/lib/galaxy/webapps/tool_shed/api/repositories.py +++ b/lib/galaxy/webapps/tool_shed/api/repositories.py @@ -113,7 +113,7 @@ # Get the repository information. repository = suc.get_repository_by_name_and_owner( trans.app, name, owner ) encoded_repository_id = trans.security.encode_id( repository.id ) - repository_dict = repository.get_api_value( view='element', value_mapper=default_repository_value_mapper( trans, repository ) ) + repository_dict = repository.dictify( view='element', value_mapper=default_repository_value_mapper( trans, repository ) ) repository_dict[ 'url' ] = web.url_for( controller='repositories', action='show', id=encoded_repository_id ) @@ -129,7 +129,7 @@ changeset_revision = new_changeset_revision if repository_metadata: encoded_repository_metadata_id = trans.security.encode_id( repository_metadata.id ) - repository_metadata_dict = repository_metadata.get_api_value( view='collection', + repository_metadata_dict = repository_metadata.dictify( view='collection', value_mapper=default_repository_metadata_value_mapper( trans, repository_metadata ) ) repository_metadata_dict[ 'url' ] = web.url_for( controller='repository_revisions', action='show', @@ -164,7 +164,7 @@ .order_by( trans.app.model.Repository.table.c.name ) \ .all() for repository in query: - repository_dict = repository.get_api_value( view='collection', value_mapper=default_repository_value_mapper( trans, repository ) ) + repository_dict = repository.dictify( view='collection', value_mapper=default_repository_value_mapper( trans, repository ) ) repository_dict[ 'url' ] = web.url_for( controller='repositories', action='show', id=trans.security.encode_id( repository.id ) ) @@ -187,7 +187,7 @@ # Example URL: http://localhost:9009/api/repositories/f9cad7b01a472135 try: repository = suc.get_repository_in_tool_shed( trans, id ) - repository_dict = repository.get_api_value( view='element', value_mapper=default_repository_value_mapper( trans, repository ) ) + repository_dict = repository.dictify( view='element', value_mapper=default_repository_value_mapper( trans, repository ) ) repository_dict[ 'url' ] = web.url_for( controller='repositories', action='show', id=trans.security.encode_id( repository.id ) ) diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/webapps/tool_shed/api/repository_revisions.py --- a/lib/galaxy/webapps/tool_shed/api/repository_revisions.py +++ b/lib/galaxy/webapps/tool_shed/api/repository_revisions.py @@ -127,7 +127,7 @@ .order_by( trans.app.model.RepositoryMetadata.table.c.repository_id ) \ .all() for repository_metadata in query: - repository_metadata_dict = repository_metadata.get_api_value( view='collection', + repository_metadata_dict = repository_metadata.dictify( view='collection', value_mapper=default_value_mapper( trans, repository_metadata ) ) repository_metadata_dict[ 'url' ] = web.url_for( controller='repository_revisions', action='show', diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 lib/galaxy/webapps/tool_shed/model/__init__.py --- a/lib/galaxy/webapps/tool_shed/model/__init__.py +++ b/lib/galaxy/webapps/tool_shed/model/__init__.py @@ -4,7 +4,7 @@ from galaxy import util from galaxy.util.bunch import Bunch from galaxy.util.hash_util import new_secure_hash -from galaxy.model.item_attrs import APIItem +from galaxy.model.item_attrs import DictifiableMixin import tool_shed.repository_types.util as rt_util from galaxy import eggs @@ -19,9 +19,9 @@ pass -class User( object, APIItem ): - api_collection_visible_keys = ( 'id', 'email' ) - api_element_visible_keys = ( 'id', 'email', 'username' ) +class User( object, DictifiableMixin ): + dict_collection_visible_keys = ( 'id', 'email' ) + dict_element_visible_keys = ( 'id', 'email', 'username' ) def __init__( self, email=None, password=None ): self.email = email @@ -61,18 +61,18 @@ return 0 -class Group( object, APIItem ): - api_collection_visible_keys = ( 'id', 'name' ) - api_element_visible_keys = ( 'id', 'name' ) +class Group( object, DictifiableMixin ): + dict_collection_visible_keys = ( 'id', 'name' ) + dict_element_visible_keys = ( 'id', 'name' ) def __init__( self, name = None ): self.name = name self.deleted = False -class Role( object, APIItem ): - api_collection_visible_keys = ( 'id', 'name' ) - api_element_visible_keys = ( 'id', 'name', 'description', 'type' ) +class Role( object, DictifiableMixin ): + dict_collection_visible_keys = ( 'id', 'name' ) + dict_element_visible_keys = ( 'id', 'name', 'description', 'type' ) private_id = None types = Bunch( PRIVATE = 'private', @@ -130,9 +130,9 @@ self.prev_session_id = prev_session_id -class Repository( object, APIItem ): - api_collection_visible_keys = ( 'id', 'name', 'type', 'description', 'user_id', 'private', 'deleted', 'times_downloaded', 'deprecated' ) - api_element_visible_keys = ( 'id', 'name', 'type', 'description', 'long_description', 'user_id', 'private', 'deleted', 'times_downloaded', +class Repository( object, DictifiableMixin ): + dict_collection_visible_keys = ( 'id', 'name', 'type', 'description', 'user_id', 'private', 'deleted', 'times_downloaded', 'deprecated' ) + dict_element_visible_keys = ( 'id', 'name', 'type', 'description', 'long_description', 'user_id', 'private', 'deleted', 'times_downloaded', 'deprecated' ) file_states = Bunch( NORMAL = 'n', NEEDS_MERGING = 'm', @@ -155,7 +155,7 @@ self.deprecated = deprecated def as_dict( self, value_mapper=None ): - return self.get_api_value( view='element', value_mapper=value_mapper ) + return self.dictify( view='element', value_mapper=value_mapper ) def can_change_type( self, app ): # Allow changing the type only if the repository has no contents, has never been installed, or has never been changed from @@ -175,7 +175,7 @@ return True return False - def get_api_value( self, view='collection', value_mapper=None ): + def dictify( self, view='collection', value_mapper=None ): if value_mapper is None: value_mapper = {} rval = {} @@ -244,10 +244,10 @@ fp.close() -class RepositoryMetadata( object, APIItem ): - api_collection_visible_keys = ( 'id', 'repository_id', 'changeset_revision', 'malicious', 'downloadable', 'has_repository_dependencies', 'includes_datatypes', +class RepositoryMetadata( object, DictifiableMixin ): + dict_collection_visible_keys = ( 'id', 'repository_id', 'changeset_revision', 'malicious', 'downloadable', 'has_repository_dependencies', 'includes_datatypes', 'includes_tools', 'includes_tool_dependencies', 'includes_tools_for_display_in_tool_panel', 'includes_workflows' ) - api_element_visible_keys = ( 'id', 'repository_id', 'changeset_revision', 'malicious', 'downloadable', 'tools_functionally_correct', 'do_not_test', + dict_element_visible_keys = ( 'id', 'repository_id', 'changeset_revision', 'malicious', 'downloadable', 'tools_functionally_correct', 'do_not_test', 'test_install_error', 'time_last_tested', 'tool_test_results', 'has_repository_dependencies', 'includes_datatypes', 'includes_tools', 'includes_tool_dependencies', 'includes_tools_for_display_in_tool_panel', 'includes_workflows' ) @@ -284,9 +284,9 @@ return False def as_dict( self, value_mapper=None ): - return self.get_api_value( view='element', value_mapper=value_mapper ) + return self.dictify( view='element', value_mapper=value_mapper ) - def get_api_value( self, view='collection', value_mapper=None ): + def dictify( self, view='collection', value_mapper=None ): if value_mapper is None: value_mapper = {} rval = {} @@ -304,9 +304,9 @@ return rval -class SkipToolTest( object, APIItem ): - api_collection_visible_keys = ( 'id', 'repository_metadata_id', 'initial_changeset_revision' ) - api_element_visible_keys = ( 'id', 'repository_metadata_id', 'initial_changeset_revision', 'comment' ) +class SkipToolTest( object, DictifiableMixin ): + dict_collection_visible_keys = ( 'id', 'repository_metadata_id', 'initial_changeset_revision' ) + dict_element_visible_keys = ( 'id', 'repository_metadata_id', 'initial_changeset_revision', 'comment' ) def __init__( self, id=None, repository_metadata_id=None, initial_changeset_revision=None, comment=None ): self.id = id @@ -315,9 +315,9 @@ self.comment = comment def as_dict( self, value_mapper=None ): - return self.get_api_value( view='element', value_mapper=value_mapper ) + return self.dictify( view='element', value_mapper=value_mapper ) - def get_api_value( self, view='collection', value_mapper=None ): + def dictify( self, view='collection', value_mapper=None ): if value_mapper is None: value_mapper = {} rval = {} @@ -335,9 +335,9 @@ return rval -class RepositoryReview( object, APIItem ): - api_collection_visible_keys = ( 'id', 'repository_id', 'changeset_revision', 'user_id', 'rating', 'deleted' ) - api_element_visible_keys = ( 'id', 'repository_id', 'changeset_revision', 'user_id', 'rating', 'deleted' ) +class RepositoryReview( object, DictifiableMixin ): + dict_collection_visible_keys = ( 'id', 'repository_id', 'changeset_revision', 'user_id', 'rating', 'deleted' ) + dict_element_visible_keys = ( 'id', 'repository_id', 'changeset_revision', 'user_id', 'rating', 'deleted' ) approved_states = Bunch( NO='no', YES='yes' ) def __init__( self, repository_id=None, changeset_revision=None, user_id=None, rating=None, deleted=False ): @@ -347,9 +347,9 @@ self.rating = rating self.deleted = deleted -class ComponentReview( object, APIItem ): - api_collection_visible_keys = ( 'id', 'repository_review_id', 'component_id', 'private', 'approved', 'rating', 'deleted' ) - api_element_visible_keys = ( 'id', 'repository_review_id', 'component_id', 'private', 'approved', 'rating', 'deleted' ) +class ComponentReview( object, DictifiableMixin ): + dict_collection_visible_keys = ( 'id', 'repository_review_id', 'component_id', 'private', 'approved', 'rating', 'deleted' ) + dict_element_visible_keys = ( 'id', 'repository_review_id', 'component_id', 'private', 'approved', 'rating', 'deleted' ) approved_states = Bunch( NO='no', YES='yes', NA='not_applicable' ) def __init__( self, repository_review_id=None, component_id=None, comment=None, private=False, approved=False, rating=None, deleted=False ): @@ -389,9 +389,9 @@ self.repository = repository -class Category( object, APIItem ): - api_collection_visible_keys = ( 'id', 'name', 'description', 'deleted' ) - api_element_visible_keys = ( 'id', 'name', 'description', 'deleted' ) +class Category( object, DictifiableMixin ): + dict_collection_visible_keys = ( 'id', 'name', 'description', 'deleted' ) + dict_element_visible_keys = ( 'id', 'name', 'description', 'deleted' ) def __init__( self, name=None, description=None, deleted=False ): self.name = name diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 templates/webapps/galaxy/base_panels.mako --- a/templates/webapps/galaxy/base_panels.mako +++ b/templates/webapps/galaxy/base_panels.mako @@ -16,7 +16,7 @@ """Bootstrapping user API JSON""" #TODO: move into common location (poss. BaseController) if trans.user: - user_dict = trans.user.get_api_value( view='element', value_mapper={ 'id': trans.security.encode_id, + user_dict = trans.user.dictify( view='element', value_mapper={ 'id': trans.security.encode_id, 'total_disk_usage': float } ) user_dict['quota_percent'] = trans.app.quota_agent.get_percent( trans=trans ) else: diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 templates/webapps/galaxy/dataset/display.mako --- a/templates/webapps/galaxy/dataset/display.mako +++ b/templates/webapps/galaxy/dataset/display.mako @@ -20,7 +20,7 @@ require(['mvc/data'], function(data) { data.createTabularDatasetChunkedView( // Dataset config. TODO: encode id. - _.extend( ${h.to_json_string( item.get_api_value() )}, + _.extend( ${h.to_json_string( item.dictify() )}, { chunk_url: "${h.url_for( controller='/dataset', action='display', dataset_id=trans.security.encode_id( item.id ))}", diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 templates/webapps/galaxy/dataset/tabular_chunked.mako --- a/templates/webapps/galaxy/dataset/tabular_chunked.mako +++ b/templates/webapps/galaxy/dataset/tabular_chunked.mako @@ -19,7 +19,7 @@ require(['mvc/data'], function(data) { data.createTabularDatasetChunkedView( - _.extend( ${h.to_json_string( trans.security.encode_dict_ids( dataset.get_api_value() ) )}, + _.extend( ${h.to_json_string( trans.security.encode_dict_ids( dataset.dictify() ) )}, { url_viz: "${h.url_for( controller='/visualization')}", chunk_url: "${h.url_for( controller='/dataset', action='display', diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 templates/webapps/galaxy/galaxy.masthead.mako --- a/templates/webapps/galaxy/galaxy.masthead.mako +++ b/templates/webapps/galaxy/galaxy.masthead.mako @@ -4,7 +4,7 @@ """Bootstrapping user API JSON""" #TODO: move into common location (poss. BaseController) if trans.user: - user_dict = trans.user.get_api_value( view='element', value_mapper={ 'id': trans.security.encode_id, + user_dict = trans.user.dictify( view='element', value_mapper={ 'id': trans.security.encode_id, 'total_disk_usage': float } ) user_dict['quota_percent'] = trans.app.quota_agent.get_percent( trans=trans ) else: diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 templates/webapps/galaxy/visualization/scatterplot.mako --- a/templates/webapps/galaxy/visualization/scatterplot.mako +++ b/templates/webapps/galaxy/visualization/scatterplot.mako @@ -222,7 +222,7 @@ <script type="text/javascript"> $(function(){ - var hda = ${h.to_json_string( trans.security.encode_dict_ids( hda.get_api_value() ) )}, + var hda = ${h.to_json_string( trans.security.encode_dict_ids( hda.dictify() ) )}, querySettings = ${h.to_json_string( query_args )}, chartConfig = _.extend( querySettings, { containerSelector : '#chart', diff -r a699decd482ce7732ea61ffb8e13714a0f991381 -r 4f4e01316260d300dc10da137cbbd5905114b7f5 templates/webapps/galaxy/visualization/v_fwork_test.mako --- a/templates/webapps/galaxy/visualization/v_fwork_test.mako +++ b/templates/webapps/galaxy/visualization/v_fwork_test.mako @@ -19,7 +19,7 @@ <%def name="process_hda( hda )"><% - hda_dict = hda.get_api_value() + hda_dict = hda.dictify() hda_dict[ 'id' ] = trans.security.encode_id( hda_dict[ 'id' ] ) hda_dict[ 'history_id' ] = trans.security.encode_id( hda_dict[ 'history_id' ] ) del hda_dict[ 'peek' ] 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)
-
commits-noreply@bitbucket.org