예제 #1
0
파일: groups.py 프로젝트: yin-max/galaxy
    def get(self, trans, decoded_group_id=None, name=None):
        """
        Get the group from the DB based on its ID or name.

        :param  decoded_group_id:       decoded group id
        :type   decoded_group_id:       int

        :returns:   the requested group
        :rtype:     Group
        """
        if decoded_group_id is None and name is None:
            raise RequestParameterInvalidException(
                'You must supply either ID or a name of the group.')

        name_query = trans.sa_session.query(trans.app.model.Group).filter(
            trans.app.model.Group.table.c.name == name)
        id_query = trans.sa_session.query(trans.app.model.Group).filter(
            trans.app.model.Group.table.c.id == decoded_group_id)

        try:
            group = id_query.one() if decoded_group_id else name_query.one()
        except MultipleResultsFound:
            raise InconsistentDatabase(
                'Multiple groups found with the same identifier.')
        except NoResultFound:
            raise ObjectNotFound(
                'No group found with the identifier provided.')
        except Exception:
            raise InternalServerError('Error loading from the database.')
        return group
예제 #2
0
    def get(self, trans, decoded_folder_id, check_manageable=False, check_accessible=True):
        """
        Get the folder from the DB.

        :param  decoded_folder_id:       decoded folder id
        :type   decoded_folder_id:       int
        :param  check_manageable:        flag whether the check that user can manage item
        :type   check_manageable:        bool
        :param  check_accessible:        flag whether to check that user can access item
        :type   check_accessible:        bool

        :returns:   the requested folder
        :rtype:     LibraryFolder

        :raises: InconsistentDatabase, RequestParameterInvalidException, InternalServerError
        """
        try:
            folder = trans.sa_session.query(trans.app.model.LibraryFolder).filter(trans.app.model.LibraryFolder.table.c.id == decoded_folder_id).one()
        except MultipleResultsFound:
            raise InconsistentDatabase('Multiple folders found with the same id.')
        except NoResultFound:
            raise RequestParameterInvalidException('No folder found with the id provided.')
        except Exception as e:
            raise InternalServerError('Error loading from the database.' + unicodify(e))
        folder = self.secure(trans, folder, check_manageable, check_accessible)
        return folder
예제 #3
0
    def get(self, trans, decoded_repo_id):
        """
        Get the repo from the DB.

        :param  decoded_repo_id:       decoded repo id
        :type   decoded_repo_id:       int

        :returns:   the requested repo
        :rtype:     Repository
        """
        try:
            repo = trans.sa_session.query(trans.app.model.Repository).filter(trans.app.model.Repository.table.c.id == decoded_repo_id).one()
        except MultipleResultsFound:
            raise InconsistentDatabase('Multiple repositories found with the same id.')
        except NoResultFound:
            raise RequestParameterInvalidException('No repository found with the id provided.')
        except Exception:
            raise InternalServerError('Error loading from the database.')
        return repo