commit/galaxy-central: martenson: pep8
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/f09f01f2b21e/ Changeset: f09f01f2b21e User: martenson Date: 2014-05-07 22:48:34 Summary: pep8 Affected #: 2 files diff -r d283202d915e6f3fc5f80330a1e85d3a32a16049 -r f09f01f2b21ed47f3dca5104ea6c00dfb6c77210 lib/galaxy/exceptions/__init__.py --- a/lib/galaxy/exceptions/__init__.py +++ b/lib/galaxy/exceptions/__init__.py @@ -37,6 +37,7 @@ # Please keep the exceptions ordered by status code + class ActionInputError( MessageException ): status_code = 400 err_code = error_codes.USER_REQUEST_INVALID_PARAMETER @@ -44,76 +45,94 @@ def __init__( self, err_msg, type="error" ): super( ActionInputError, self ).__init__( err_msg, type ) + class DuplicatedSlugException( MessageException ): status_code = 400 err_code = error_codes.USER_SLUG_DUPLICATE + class ObjectAttributeInvalidException( MessageException ): status_code = 400 err_code = error_codes.USER_OBJECT_ATTRIBUTE_INVALID + class ObjectAttributeMissingException( MessageException ): status_code = 400 err_code = error_codes.USER_OBJECT_ATTRIBUTE_MISSING + class MalformedId( MessageException ): status_code = 400 err_code = error_codes.MALFORMED_ID + class UnknownContentsType( MessageException ): status_code = 400 err_code = error_codes.UNKNOWN_CONTENTS_TYPE + class RequestParameterMissingException( MessageException ): status_code = 400 err_code = error_codes.USER_REQUEST_MISSING_PARAMETER + class ToolMetaParameterException( MessageException ): status_code = 400 err_code = error_codes.USER_TOOL_META_PARAMETER_PROBLEM + class RequestParameterInvalidException( MessageException ): status_code = 400 err_code = error_codes.USER_REQUEST_INVALID_PARAMETER + class AuthenticationRequired( MessageException ): status_code = 403 #TODO: as 401 and send WWW-Authenticate: ??? err_code = error_codes.USER_NO_API_KEY + class ItemAccessibilityException( MessageException ): status_code = 403 err_code = error_codes.USER_CANNOT_ACCESS_ITEM + class ItemOwnershipException( MessageException ): status_code = 403 err_code = error_codes.USER_DOES_NOT_OWN_ITEM + class ConfigDoesNotAllowException( MessageException ): status_code = 403 err_code = error_codes.CONFIG_DOES_NOT_ALLOW + class InsufficientPermissionsException( MessageException ): status_code = 403 err_code = error_codes.INSUFFICIENT_PERMISSIONS + class ObjectNotFound( MessageException ): """ Accessed object was not found """ status_code = 404 err_code = error_codes.USER_OBJECT_NOT_FOUND + class Conflict( MessageException ): status_code = 409 err_code = error_codes.CONFLICT + class InconsistentDatabase ( MessageException ): status_code = 500 err_code = error_codes.INCONSISTENT_DATABASE + class InternalServerError ( MessageException ): status_code = 500 err_code = error_codes.INTERNAL_SERVER_ERROR + class NotImplemented ( MessageException ): status_code = 501 err_code = error_codes.NOT_IMPLEMENTED diff -r d283202d915e6f3fc5f80330a1e85d3a32a16049 -r f09f01f2b21ed47f3dca5104ea6c00dfb6c77210 lib/galaxy/webapps/galaxy/api/libraries.py --- a/lib/galaxy/webapps/galaxy/api/libraries.py +++ b/lib/galaxy/webapps/galaxy/api/libraries.py @@ -2,7 +2,6 @@ API operations on a data library. """ from galaxy import util -from galaxy import web from galaxy import exceptions from galaxy.web import _future_expose_api as expose_api from galaxy.web import _future_expose_api_anonymous as expose_api_anonymous @@ -12,6 +11,7 @@ import logging log = logging.getLogger( __name__ ) + class LibrariesController( BaseAPIController ): @expose_api_anonymous @@ -33,7 +33,8 @@ query = trans.sa_session.query( trans.app.model.Library ) deleted = kwd.get( 'deleted', 'missing' ) try: - if not trans.user_is_admin(): # non-admins can't see deleted libraries + if not trans.user_is_admin(): + # non-admins can't see deleted libraries deleted = False else: deleted = util.asbool( deleted ) @@ -48,16 +49,15 @@ current_user_role_ids = [ role.id for role in trans.get_current_user_roles() ] library_access_action = trans.app.security_agent.permitted_actions.LIBRARY_ACCESS.action restricted_library_ids = [ lp.library_id for lp in ( trans.sa_session.query( trans.model.LibraryPermissions ) - .filter( trans.model.LibraryPermissions.table.c.action == library_access_action ) - .distinct() ) ] + .filter( trans.model.LibraryPermissions.table.c.action == library_access_action ) + .distinct() ) ] accessible_restricted_library_ids = [ lp.library_id for lp in ( trans.sa_session.query( trans.model.LibraryPermissions ) - .filter( and_( trans.model.LibraryPermissions.table.c.action == library_access_action, - trans.model.LibraryPermissions.table.c.role_id.in_( current_user_role_ids ) ) ) ) ] - query = query.filter( or_( not_( trans.model.Library.table.c.id.in_( restricted_library_ids ) ), - trans.model.Library.table.c.id.in_( accessible_restricted_library_ids ) ) ) + .filter( and_( trans.model.LibraryPermissions.table.c.action == library_access_action, + trans.model.LibraryPermissions.table.c.role_id.in_( current_user_role_ids ) ) ) ) ] + query = query.filter( or_( not_( trans.model.Library.table.c.id.in_( restricted_library_ids ) ), trans.model.Library.table.c.id.in_( accessible_restricted_library_ids ) ) ) libraries = [] for library in query: - item = library.to_dict( view='element', value_mapper={ 'id' : trans.security.encode_id , 'root_folder_id' : trans.security.encode_id } ) + item = library.to_dict( view='element', value_mapper={ 'id': trans.security.encode_id, 'root_folder_id': trans.security.encode_id } ) if trans.app.security_agent.library_is_public( library, contents=False ): item[ 'public' ] = True current_user_roles = trans.get_current_user_roles() @@ -106,7 +106,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 exceptions.ObjectNotFound( 'Library with the id provided ( %s ) was not found' % id ) - return library.to_dict( view='element', value_mapper={ 'id' : trans.security.encode_id , 'root_folder_id' : trans.security.encode_id } ) + return library.to_dict( view='element', value_mapper={ 'id': trans.security.encode_id, 'root_folder_id': trans.security.encode_id } ) @expose_api def create( self, trans, payload, **kwd ): @@ -144,7 +144,7 @@ trans.sa_session.add_all( ( library, root_folder ) ) trans.sa_session.flush() - item = library.to_dict( view='element', value_mapper={ 'id' : trans.security.encode_id , 'root_folder_id' : trans.security.encode_id } ) + item = library.to_dict( view='element', value_mapper={ 'id': trans.security.encode_id, 'root_folder_id': trans.security.encode_id } ) item['can_user_add'] = True item['can_user_modify'] = True item['can_user_manage'] = True @@ -204,7 +204,7 @@ raise exceptions.RequestParameterMissingException( "You did not specify any payload." ) trans.sa_session.add( library ) trans.sa_session.flush() - return library.to_dict( view='element', value_mapper={ 'id' : trans.security.encode_id , 'root_folder_id' : trans.security.encode_id } ) + return library.to_dict( view='element', value_mapper={ 'id': trans.security.encode_id, 'root_folder_id': trans.security.encode_id } ) @expose_api def delete( self, trans, id, **kwd ): @@ -249,5 +249,4 @@ trans.sa_session.add( library ) trans.sa_session.flush() - return library.to_dict( view='element', value_mapper={ 'id' : trans.security.encode_id , 'root_folder_id' : trans.security.encode_id } ) - + return library.to_dict( view='element', value_mapper={ 'id': trans.security.encode_id, 'root_folder_id': trans.security.encode_id } ) 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