From dcd4e48084d72f8b6fcd6163cfef2f9e2830a08f Mon Sep 17 00:00:00 2001 From: Jeremy Goecks Date: Sun, 27 May 2012 16:09:16 -0400 Subject: [PATCH] Include 'mixin' in names of many common controller mixins. --- lib/galaxy/tools/genome_index/__init__.py | 12 +------- lib/galaxy/tools/imp_exp/__init__.py | 6 ++-- lib/galaxy/web/api/datasets.py | 2 +- lib/galaxy/web/api/histories.py | 4 +-- lib/galaxy/web/api/history_contents.py | 2 +- lib/galaxy/web/api/library_contents.py | 2 +- lib/galaxy/web/api/quotas.py | 4 +-- lib/galaxy/web/base/controller.py | 28 +++++++++---------- lib/galaxy/web/controllers/admin.py | 2 +- lib/galaxy/web/controllers/dataset.py | 2 +- .../web/controllers/external_service.py | 2 +- lib/galaxy/web/controllers/history.py | 2 +- lib/galaxy/web/controllers/library_common.py | 2 +- lib/galaxy/web/controllers/page.py | 4 +-- lib/galaxy/web/controllers/request_type.py | 2 +- lib/galaxy/web/controllers/requests_admin.py | 2 +- lib/galaxy/web/controllers/requests_common.py | 2 +- lib/galaxy/web/controllers/root.py | 2 +- lib/galaxy/web/controllers/tracks.py | 2 +- lib/galaxy/web/controllers/user.py | 2 +- lib/galaxy/web/controllers/visualization.py | 4 +-- lib/galaxy/web/controllers/workflow.py | 2 +- 22 files changed, 41 insertions(+), 51 deletions(-) diff --git a/lib/galaxy/tools/genome_index/__init__.py b/lib/galaxy/tools/genome_index/__init__.py index cf89fb8d065..650ca17d53b 100644 --- a/lib/galaxy/tools/genome_index/__init__.py +++ b/lib/galaxy/tools/genome_index/__init__.py @@ -3,7 +3,7 @@ from galaxy import model, util from galaxy.web.framework.helpers import to_unicode from galaxy.model.item_attrs import UsesAnnotations from galaxy.util.json import * -from galaxy.web.base.controller import UsesHistory +from galaxy.web.base.controller import UsesHistoryMixin from galaxy.tools.data import ToolDataTableManager log = logging.getLogger(__name__) @@ -63,8 +63,6 @@ class GenomeIndexToolWrapper( object ): if gitd: destination = None - alldone = True - indexjobs = gitd.deferred.params[ 'indexjobs' ] tdtman = ToolDataTableManager() xmltree = tdtman.load_from_config_file(app.config.tool_data_table_config_path) for node in xmltree: @@ -165,14 +163,6 @@ class GenomeIndexToolWrapper( object ): self._check_link( fasta, target ) for line in location: self._add_line( line[ 'file' ], line[ 'line' ] ) - for indexjob in indexjobs: - js = sa_session.query( model.Job ).filter_by( id=indexjob ).first() - if js.state not in [ 'ok', 'done', 'error' ]: - alldone = False - if alldone: - gitd.deferred.state = 'ok' - sa_session.add( gitd.deferred ) - sa_session.flush() def _check_link( self, targetfile, symlink ): target = os.path.relpath( targetfile, os.path.dirname( symlink ) ) diff --git a/lib/galaxy/tools/imp_exp/__init__.py b/lib/galaxy/tools/imp_exp/__init__.py index c38e2cecbd9..251c98209cb 100644 --- a/lib/galaxy/tools/imp_exp/__init__.py +++ b/lib/galaxy/tools/imp_exp/__init__.py @@ -4,7 +4,7 @@ from galaxy.tools.parameters.basic import UnvalidatedValue from galaxy.web.framework.helpers import to_unicode from galaxy.model.item_attrs import UsesAnnotations from galaxy.util.json import * -from galaxy.web.base.controller import UsesHistory +from galaxy.web.base.controller import UsesHistoryMixin log = logging.getLogger(__name__) @@ -42,7 +42,7 @@ def load_history_imp_exp_tools( toolbox ): toolbox.tools_by_id[ history_imp_tool.id ] = history_imp_tool log.debug( "Loaded history import tool: %s", history_imp_tool.id ) -class JobImportHistoryArchiveWrapper( object, UsesHistory, UsesAnnotations ): +class JobImportHistoryArchiveWrapper( object, UsesHistoryMixin, UsesAnnotations ): """ Class provides support for performing jobs that import a history from an archive. @@ -263,7 +263,7 @@ class JobImportHistoryArchiveWrapper( object, UsesHistory, UsesAnnotations ): jiha.job.stderr += "Error cleaning up history import job: %s" % e db_session.flush() -class JobExportHistoryArchiveWrapper( object, UsesHistory, UsesAnnotations ): +class JobExportHistoryArchiveWrapper( object, UsesHistoryMixin, UsesAnnotations ): """ Class provides support for performing jobs that export a history to an archive. diff --git a/lib/galaxy/web/api/datasets.py b/lib/galaxy/web/api/datasets.py index b11dc19fe77..e26d412bf9e 100644 --- a/lib/galaxy/web/api/datasets.py +++ b/lib/galaxy/web/api/datasets.py @@ -10,7 +10,7 @@ from galaxy.model.orm import * log = logging.getLogger( __name__ ) -class DatasetsController( BaseAPIController, UsesHistoryDatasetAssociation ): +class DatasetsController( BaseAPIController, UsesHistoryMixinDatasetAssociationMixin ): @web.expose_api def index( self, trans, hda_id, **kwd ): diff --git a/lib/galaxy/web/api/histories.py b/lib/galaxy/web/api/histories.py index ffe3c5a3b7a..7ab1bc18c8d 100644 --- a/lib/galaxy/web/api/histories.py +++ b/lib/galaxy/web/api/histories.py @@ -12,7 +12,7 @@ from galaxy.util.bunch import Bunch log = logging.getLogger( __name__ ) -class HistoriesController( BaseAPIController, UsesHistory ): +class HistoriesController( BaseAPIController, UsesHistoryMixin ): @web.expose_api def index( self, trans, deleted='False', **kwd ): @@ -153,7 +153,7 @@ class HistoriesController( BaseAPIController, UsesHistory ): POST /api/histories/deleted/{encoded_quota_id}/undelete Undeletes a quota """ - history = self.get_history( trans, id, check_ownership=True, check_accessible=False, deleted=True ) + history = self.get_history( trans, history_id, check_ownership=True, check_accessible=False, deleted=True ) history.deleted = False trans.sa_session.add( history ) trans.sa_session.flush() diff --git a/lib/galaxy/web/api/history_contents.py b/lib/galaxy/web/api/history_contents.py index ddcb37d75fe..1383518154b 100644 --- a/lib/galaxy/web/api/history_contents.py +++ b/lib/galaxy/web/api/history_contents.py @@ -12,7 +12,7 @@ import routes log = logging.getLogger( __name__ ) -class HistoryContentsController( BaseAPIController, UsesHistoryDatasetAssociation, UsesHistory, UsesLibrary, UsesLibraryItems ): +class HistoryContentsController( BaseAPIController, UsesHistoryMixinDatasetAssociationMixin, UsesHistoryMixin, UsesLibraryMixin, UsesLibraryMixinItems ): @web.expose_api def index( self, trans, history_id, **kwd ): diff --git a/lib/galaxy/web/api/library_contents.py b/lib/galaxy/web/api/library_contents.py index c49a63dd11c..b493d34e190 100644 --- a/lib/galaxy/web/api/library_contents.py +++ b/lib/galaxy/web/api/library_contents.py @@ -10,7 +10,7 @@ from galaxy.model.orm import * log = logging.getLogger( __name__ ) -class LibraryContentsController( BaseAPIController, UsesLibrary, UsesLibraryItems ): +class LibraryContentsController( BaseAPIController, UsesLibraryMixin, UsesLibraryMixinItems ): @web.expose_api def index( self, trans, library_id, **kwd ): diff --git a/lib/galaxy/web/api/quotas.py b/lib/galaxy/web/api/quotas.py index db8ffe1fe6d..91fc87655f7 100644 --- a/lib/galaxy/web/api/quotas.py +++ b/lib/galaxy/web/api/quotas.py @@ -2,7 +2,7 @@ API operations on Quota objects. """ import logging -from galaxy.web.base.controller import BaseAPIController, Admin, UsesQuota, url_for +from galaxy.web.base.controller import BaseAPIController, Admin, UsesQuotaMixin, url_for from galaxy import web, util from elementtree.ElementTree import XML @@ -14,7 +14,7 @@ from galaxy.exceptions import * log = logging.getLogger( __name__ ) -class QuotaAPIController( BaseAPIController, Admin, AdminActions, UsesQuota, QuotaParamParser ): +class QuotaAPIController( BaseAPIController, Admin, AdminActions, UsesQuotaMixin, QuotaParamParser ): @web.expose_api @web.require_admin def index( self, trans, deleted='False', **kwd ): diff --git a/lib/galaxy/web/base/controller.py b/lib/galaxy/web/base/controller.py index 8acc27d3e0f..4495c2e3328 100644 --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -177,7 +177,11 @@ class BaseAPIController( BaseController ): def not_implemented( self, trans, **kwd ): raise HTTPNotImplemented() -class SharableItemSecurity: +# +# -- Mixins for working with Galaxy objects. -- +# + +class SharableItemSecurityMixin: """ Mixin for handling security for sharable items. """ def security_check( self, trans, item, check_ownership=False, check_accessible=False ): """ Security checks for an item: checks if (a) user owns item or (b) item is accessible to user. """ @@ -197,11 +201,7 @@ class SharableItemSecurity: raise ItemAccessibilityException( "%s is not accessible to the current user" % item.__class__.__name__, type='error' ) return item -# -# TODO: need to move UsesHistory, etc. mixins to better location - perhaps lib/galaxy/model/XXX ? -# - -class UsesHistoryDatasetAssociation: +class UsesHistoryMixinDatasetAssociationMixin: """ Mixin for controllers that use HistoryDatasetAssociation objects. """ def get_dataset( self, trans, dataset_id, check_ownership=True, check_accessible=False ): """ Get an HDA object by id. """ @@ -259,14 +259,14 @@ class UsesHistoryDatasetAssociation: truncated = False return truncated, dataset_data -class UsesLibrary: +class UsesLibraryMixin: def get_library( self, trans, id, check_ownership=False, check_accessible=True ): l = self.get_object( trans, id, 'Library' ) if check_accessible and not ( trans.user_is_admin() or trans.app.security_agent.can_access_library( trans.get_current_user_roles(), l ) ): error( "LibraryFolder is not accessible to the current user" ) return l -class UsesLibraryItems( SharableItemSecurity ): +class UsesLibraryMixinItems( SharableItemSecurityMixin ): def get_library_folder( self, trans, id, check_ownership=False, check_accessible=True ): return self.get_object( trans, id, 'LibraryFolder', check_ownership=False, check_accessible=check_accessible ) def get_library_dataset_dataset_association( self, trans, id, check_ownership=False, check_accessible=True ): @@ -274,7 +274,7 @@ class UsesLibraryItems( SharableItemSecurity ): def get_library_dataset( self, trans, id, check_ownership=False, check_accessible=True ): return self.get_object( trans, id, 'LibraryDataset', check_ownership=False, check_accessible=check_accessible ) -class UsesVisualization( SharableItemSecurity ): +class UsesVisualizationMixin( SharableItemSecurityMixin ): """ Mixin for controllers that use Visualization objects. """ viz_types = [ "trackster", "circos" ] @@ -522,7 +522,7 @@ class UsesVisualization( SharableItemSecurity ): return visualization -class UsesStoredWorkflow( SharableItemSecurity ): +class UsesStoredWorkflowMixin( SharableItemSecurityMixin ): """ Mixin for controllers that use StoredWorkflow objects. """ def get_stored_workflow( self, trans, id, check_ownership=True, check_accessible=False ): """ Get a StoredWorkflow from the database by id, verifying ownership. """ @@ -560,7 +560,7 @@ class UsesStoredWorkflow( SharableItemSecurity ): # Connections by input name step.input_connections_by_name = dict( ( conn.input_name, conn ) for conn in step.input_connections ) -class UsesHistory( SharableItemSecurity ): +class UsesHistoryMixin( SharableItemSecurityMixin ): """ Mixin for controllers that use History objects. """ def get_history( self, trans, id, check_ownership=True, check_accessible=False, deleted=None ): """Get a History from the database by id, verifying ownership.""" @@ -580,7 +580,7 @@ class UsesHistory( SharableItemSecurity ): query = query.filter( trans.model.Dataset.purged == False ) return query.all() -class UsesFormDefinitions: +class UsesFormDefinitionsMixin: """Mixin for controllers that use Galaxy form objects.""" def get_all_forms( self, trans, all_versions=False, filter=None, form_type='All' ): """ @@ -1342,7 +1342,7 @@ class UsesFormDefinitions: selected_value=selected_value, refresh_on_change=True ) -class Sharable: +class SharableMixin: """ Mixin for a controller that manages an item that can be shared. """ # -- Implemented methods. -- @@ -1433,7 +1433,7 @@ class Sharable: """ Return item based on id. """ raise "Unimplemented Method" -class UsesQuota( object ): +class UsesQuotaMixin( object ): def get_quota( self, trans, id, check_ownership=False, check_accessible=False, deleted=None ): return self.get_object( trans, id, 'Quota', check_ownership=False, check_accessible=False, deleted=deleted ) diff --git a/lib/galaxy/web/controllers/admin.py b/lib/galaxy/web/controllers/admin.py index c1952850abc..6990cdacf0e 100644 --- a/lib/galaxy/web/controllers/admin.py +++ b/lib/galaxy/web/controllers/admin.py @@ -428,7 +428,7 @@ class ToolVersionListGrid( grids.Grid ): def build_initial_query( self, trans, **kwd ): return trans.sa_session.query( self.model_class ) -class AdminGalaxy( BaseUIController, Admin, AdminActions, UsesQuota, QuotaParamParser ): +class AdminGalaxy( BaseUIController, Admin, AdminActions, UsesQuotaMixin, QuotaParamParser ): user_list_grid = UserListGrid() role_list_grid = RoleListGrid() diff --git a/lib/galaxy/web/controllers/dataset.py b/lib/galaxy/web/controllers/dataset.py index be0bc09dcaf..78d9742dc2d 100644 --- a/lib/galaxy/web/controllers/dataset.py +++ b/lib/galaxy/web/controllers/dataset.py @@ -150,7 +150,7 @@ class HistoryDatasetAssociationListGrid( grids.Grid ): .filter( model.History.deleted==False ) \ .filter( self.model_class.visible==True ) -class DatasetInterface( BaseUIController, UsesAnnotations, UsesHistory, UsesHistoryDatasetAssociation, UsesItemRatings ): +class DatasetInterface( BaseUIController, UsesAnnotations, UsesHistoryMixin, UsesHistoryMixinDatasetAssociationMixin, UsesItemRatings ): stored_list_grid = HistoryDatasetAssociationListGrid() diff --git a/lib/galaxy/web/controllers/external_service.py b/lib/galaxy/web/controllers/external_service.py index d3f520b0f85..fd127ecf409 100644 --- a/lib/galaxy/web/controllers/external_service.py +++ b/lib/galaxy/web/controllers/external_service.py @@ -63,7 +63,7 @@ class ExternalServiceGrid( grids.Grid ): grids.GridAction( "Create new external service", dict( controller='external_service', action='create_external_service' ) ) ] -class ExternalService( BaseUIController, UsesFormDefinitions ): +class ExternalService( BaseUIController, UsesFormDefinitionsMixin ): external_service_grid = ExternalServiceGrid() @web.expose diff --git a/lib/galaxy/web/controllers/history.py b/lib/galaxy/web/controllers/history.py index c01df14d1c7..d6d2fd2f6e2 100644 --- a/lib/galaxy/web/controllers/history.py +++ b/lib/galaxy/web/controllers/history.py @@ -190,7 +190,7 @@ class HistoryAllPublishedGrid( grids.Grid ): # A public history is published, has a slug, and is not deleted. return query.filter( self.model_class.published == True ).filter( self.model_class.slug != None ).filter( self.model_class.deleted == False ) -class HistoryController( BaseUIController, Sharable, UsesAnnotations, UsesItemRatings, UsesHistory ): +class HistoryController( BaseUIController, SharableMixin, UsesAnnotations, UsesItemRatings, UsesHistoryMixin ): @web.expose def index( self, trans ): return "" diff --git a/lib/galaxy/web/controllers/library_common.py b/lib/galaxy/web/controllers/library_common.py index 286dbca3c21..38d8eb1de04 100644 --- a/lib/galaxy/web/controllers/library_common.py +++ b/lib/galaxy/web/controllers/library_common.py @@ -68,7 +68,7 @@ except OSError: pass os.rmdir( tmpd ) -class LibraryCommon( BaseUIController, UsesFormDefinitions ): +class LibraryCommon( BaseUIController, UsesFormDefinitionsMixin ): @web.json def library_item_updates( self, trans, ids=None, states=None ): # Avoid caching diff --git a/lib/galaxy/web/controllers/page.py b/lib/galaxy/web/controllers/page.py index 200f279bd96..8cf78a5334a 100644 --- a/lib/galaxy/web/controllers/page.py +++ b/lib/galaxy/web/controllers/page.py @@ -272,8 +272,8 @@ class _PageContentProcessor( _BaseHTMLProcessor ): # Default behavior: _BaseHTMLProcessor.unknown_endtag( self, tag ) -class PageController( BaseUIController, Sharable, UsesAnnotations, UsesHistory, - UsesStoredWorkflow, UsesHistoryDatasetAssociation, UsesVisualization, UsesItemRatings ): +class PageController( BaseUIController, SharableMixin, UsesAnnotations, UsesHistoryMixin, + UsesStoredWorkflowMixin, UsesHistoryMixinDatasetAssociationMixin, UsesVisualizationMixin, UsesItemRatings ): _page_list = PageListGrid() _all_published_list = PageAllPublishedGrid() diff --git a/lib/galaxy/web/controllers/request_type.py b/lib/galaxy/web/controllers/request_type.py index d327ca8771d..699f8c8caf8 100644 --- a/lib/galaxy/web/controllers/request_type.py +++ b/lib/galaxy/web/controllers/request_type.py @@ -72,7 +72,7 @@ class RequestTypeGrid( grids.Grid ): grids.GridAction( "Create new request type", dict( controller='request_type', action='create_request_type' ) ) ] -class RequestType( BaseUIController, UsesFormDefinitions ): +class RequestType( BaseUIController, UsesFormDefinitionsMixin ): request_type_grid = RequestTypeGrid() @web.expose diff --git a/lib/galaxy/web/controllers/requests_admin.py b/lib/galaxy/web/controllers/requests_admin.py index 683e3618b9d..0bfe7537cbb 100644 --- a/lib/galaxy/web/controllers/requests_admin.py +++ b/lib/galaxy/web/controllers/requests_admin.py @@ -94,7 +94,7 @@ class DataTransferGrid( grids.Grid ): return query return query.filter_by( sample_id=trans.security.decode_id( sample_id ) ) -class RequestsAdmin( BaseUIController, UsesFormDefinitions ): +class RequestsAdmin( BaseUIController, UsesFormDefinitionsMixin ): request_grid = AdminRequestsGrid() datatx_grid = DataTransferGrid() diff --git a/lib/galaxy/web/controllers/requests_common.py b/lib/galaxy/web/controllers/requests_common.py index 88bbc3320f8..6d796eae80e 100644 --- a/lib/galaxy/web/controllers/requests_common.py +++ b/lib/galaxy/web/controllers/requests_common.py @@ -93,7 +93,7 @@ class RequestsGrid( grids.Grid ): confirm="Samples cannot be added to this request after it is submitted. Click OK to submit." ) ] -class RequestsCommon( BaseUIController, UsesFormDefinitions ): +class RequestsCommon( BaseUIController, UsesFormDefinitionsMixin ): @web.json def sample_state_updates( self, trans, ids=None, states=None ): # Avoid caching diff --git a/lib/galaxy/web/controllers/root.py b/lib/galaxy/web/controllers/root.py index c0c566f58de..3e51abc6855 100644 --- a/lib/galaxy/web/controllers/root.py +++ b/lib/galaxy/web/controllers/root.py @@ -11,7 +11,7 @@ from galaxy.model.item_attrs import UsesAnnotations log = logging.getLogger( __name__ ) -class RootController( BaseUIController, UsesHistory, UsesAnnotations ): +class RootController( BaseUIController, UsesHistoryMixin, UsesAnnotations ): @web.expose def default(self, trans, target1=None, target2=None, **kwd): diff --git a/lib/galaxy/web/controllers/tracks.py b/lib/galaxy/web/controllers/tracks.py index a0d695c5965..8d5575eddb7 100644 --- a/lib/galaxy/web/controllers/tracks.py +++ b/lib/galaxy/web/controllers/tracks.py @@ -163,7 +163,7 @@ class TracksterSelectionGrid( grids.Grid ): def apply_query_filter( self, trans, query, **kwargs ): return query.filter( self.model_class.user_id == trans.user.id ) -class TracksController( BaseUIController, UsesVisualization, UsesHistoryDatasetAssociation, Sharable ): +class TracksController( BaseUIController, UsesVisualizationMixin, UsesHistoryMixinDatasetAssociationMixin, SharableMixin ): """ Controller for track browser interface. Handles building a new browser from datasets in the current history, and display of the resulting browser. diff --git a/lib/galaxy/web/controllers/user.py b/lib/galaxy/web/controllers/user.py index 03e49ba90cf..b897f2155ac 100644 --- a/lib/galaxy/web/controllers/user.py +++ b/lib/galaxy/web/controllers/user.py @@ -38,7 +38,7 @@ class UserOpenIDGrid( grids.Grid ): def build_initial_query( self, trans, **kwd ): return trans.sa_session.query( self.model_class ).filter( self.model_class.user_id == trans.user.id ) -class User( BaseUIController, UsesFormDefinitions ): +class User( BaseUIController, UsesFormDefinitionsMixin ): user_openid_grid = UserOpenIDGrid() installed_len_files = None diff --git a/lib/galaxy/web/controllers/visualization.py b/lib/galaxy/web/controllers/visualization.py index f41f23a6b00..4d2a56d68d3 100644 --- a/lib/galaxy/web/controllers/visualization.py +++ b/lib/galaxy/web/controllers/visualization.py @@ -68,8 +68,8 @@ class VisualizationAllPublishedGrid( grids.Grid ): return query.filter( self.model_class.deleted==False ).filter( self.model_class.published==True ) -class VisualizationController( BaseUIController, Sharable, UsesAnnotations, - UsesHistoryDatasetAssociation, UsesVisualization, +class VisualizationController( BaseUIController, SharableMixin, UsesAnnotations, + UsesHistoryMixinDatasetAssociationMixin, UsesVisualizationMixin, UsesItemRatings ): _user_list_grid = VisualizationListGrid() _published_list_grid = VisualizationAllPublishedGrid() diff --git a/lib/galaxy/web/controllers/workflow.py b/lib/galaxy/web/controllers/workflow.py index 2ebba59cd62..0942328bacc 100644 --- a/lib/galaxy/web/controllers/workflow.py +++ b/lib/galaxy/web/controllers/workflow.py @@ -105,7 +105,7 @@ class SingleTagContentsParser( sgmllib.SGMLParser ): if self.cur_tag == self.target_tag: self.tag_content += text -class WorkflowController( BaseUIController, Sharable, UsesStoredWorkflow, UsesAnnotations, UsesItemRatings ): +class WorkflowController( BaseUIController, SharableMixin, UsesStoredWorkflowMixin, UsesAnnotations, UsesItemRatings ): stored_list_grid = StoredWorkflowListGrid() published_list_grid = StoredWorkflowAllPublishedGrid()