mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Include 'mixin' in names of many common controller mixins.
This commit is contained in:
@@ -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 ) )
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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 ):
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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 ):
|
||||
|
||||
@@ -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 ):
|
||||
|
||||
@@ -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 ):
|
||||
|
||||
@@ -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 )
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 ""
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user