def dataset_purge(context, data_dict):
 from sqlalchemy import or_
 model = context['model']
 id = _get_or_bust(data_dict, 'id')
 pkg = model.Package.get(id)
 context['package'] = pkg
 if (pkg is None):
  raise NotFound('Dataset was not found')
 _check_access('dataset_purge', context, data_dict)
 members = model.Session.query(model.Member).filter((model.Member.table_id == pkg.id)).filter((model.Member.table_name == 'package'))
 if (members.count() > 0):
  for m in members.all():
   m.purge()
 for r in model.Session.query(model.PackageRelationship).filter(or_((model.PackageRelationship.subject_package_id == pkg.id), (model.PackageRelationship.object_package_id == pkg.id))).all():
  r.purge()
 pkg = model.Package.get(id)
 pkg.purge()
 model.repo.commit_and_remove()

def dataset_purge ( context , data_dict ) : from sqlalchemy import or_ model = context [ 'model' ] id = _get_or_bust ( data_dict , 'id' ) pkg = model . Package . get ( id ) context [ 'package' ] = pkg if ( pkg is None ) : raise NotFound ( 'Dataset was not found' ) _check_access ( 'dataset_purge' , context , data_dict ) members = model . Session . query ( model . Member ) . filter ( ( model . Member . table_id == pkg . id ) ) . filter ( ( model . Member . table_name == 'package' ) ) if ( members . count ( ) > 0 ) : for m in members . all ( ) : m . purge ( ) for r in model . Session . query ( model . PackageRelationship ) . filter ( or_ ( ( model . PackageRelationship . subject_package_id == pkg . id ) , ( model . PackageRelationship . object_package_id == pkg . id ) ) ) . all ( ) : r . purge ( ) pkg = model . Package . get ( id ) pkg . purge ( ) model . repo . commit_and_remove ( )
purge a dataset .