def resource_delete(context, data_dict):
 model = context['model']
 id = _get_or_bust(data_dict, 'id')
 entity = model.Resource.get(id)
 if (entity is None):
  raise NotFound
 _check_access('resource_delete', context, data_dict)
 package_id = entity.get_package_id()
 pkg_dict = _get_action('package_show')(context, {'id': package_id})
 for plugin in plugins.PluginImplementations(plugins.IResourceController):
  plugin.before_delete(context, data_dict, pkg_dict.get('resources', []))
 if pkg_dict.get('resources'):
  pkg_dict['resources'] = [r for r in pkg_dict['resources'] if (not (r['id'] == id))]
 try:
  pkg_dict = _get_action('package_update')(context, pkg_dict)
 except ValidationError as e:
  errors = e.error_dict['resources'][(-1)]
  raise ValidationError(errors)
 for plugin in plugins.PluginImplementations(plugins.IResourceController):
  plugin.after_delete(context, pkg_dict.get('resources', []))
 model.repo.commit()

def resource_delete ( context , data_dict ) : model = context [ 'model' ] id = _get_or_bust ( data_dict , 'id' ) entity = model . Resource . get ( id ) if ( entity is None ) : raise NotFound _check_access ( 'resource_delete' , context , data_dict ) package_id = entity . get_package_id ( ) pkg_dict = _get_action ( 'package_show' ) ( context , { 'id' : package_id } ) for plugin in plugins . PluginImplementations ( plugins . IResourceController ) : plugin . before_delete ( context , data_dict , pkg_dict . get ( 'resources' , [ ] ) ) if pkg_dict . get ( 'resources' ) : pkg_dict [ 'resources' ] = [ r for r in pkg_dict [ 'resources' ] if ( not ( r [ 'id' ] == id ) ) ] try : pkg_dict = _get_action ( 'package_update' ) ( context , pkg_dict ) except ValidationError as e : errors = e . error_dict [ 'resources' ] [ ( - 1 ) ] raise ValidationError ( errors ) for plugin in plugins . PluginImplementations ( plugins . IResourceController ) : plugin . after_delete ( context , pkg_dict . get ( 'resources' , [ ] ) ) model . repo . commit ( )
delete a resource from a dataset .