def delete(cls, item_id): ''' :param item_id: ''' to_delete = Session.query(cls.m).get(item_id) if to_delete is not None: Session.delete(to_delete) Session.commit()
def delete_doi(cls, identifier): ''' Delete the record with a given DOI. :param identifier: the DOI string :return: True if a record was deleted, False if not ''' to_delete = cls.read_doi(identifier) if to_delete is not None: Session.delete(to_delete) Session.commit() return True else: return False
def delete_package(cls, package_id): ''' Delete the record associated with a given package. :param package_id: the id of the package :return: True if a record was deleted, False if not ''' to_delete = cls.read_package(package_id) if to_delete is not None: Session.delete(to_delete) Session.commit() return True else: return False
def delete(self, commit=True): session = Session() session.delete(self) if commit: session.commit()
def delete_doi(package_id): """Delete the doi associated with a package_id""" doi = Session.query(DOI).filter(DOI.package_id == package_id).first() Session.delete(doi) Session.commit()