delete an instance or a class
called via ajax

@throws common_exception_BadRequest
@throws common_exception_MissingParameter
185727
public function delete()
    {
        if (!$this->isXmlHttpRequest()) {
            throw new common_exception_BadRequest('wrong request mode');
        }

        if ($this->hasRequestParameter('uri')) {
            return $this->forward('deleteResource', null, null, (array('id' => tao_helpers_Uri::decode($this->getRequestParameter('uri')))));
        } elseif ($this->hasRequestParameter('classUri')) {
            return $this->forward('deleteClass', null, null, (array('id' => tao_helpers_Uri::decode($this->getRequestParameter('classUri')))));
        } else {
            throw new common_exception_MissingParameter();
        }
    }
516073
final public function delete() {
        global $DB;

        if ($this->raw_get('id') <= 0) {
            throw new coding_exception('id is required to delete');
        }

        // Hook before delete.
        $this->before_delete();

        $result = $DB->delete_records(static::TABLE, array('id' => $this->raw_get('id')));

        // Hook after delete.
        $this->after_delete($result);

        // Reset the ID to avoid any confusion, this also invalidates the model's data.
        if ($result) {
            $this->raw_set('id', 0);
        }

        return $result;
    }
963766
public void remove() throws ProponoException {
        if (getEditURI() == null) {
            throw new ProponoException("ERROR: cannot delete unsaved entry");
        }
        final DeleteMethod method = new DeleteMethod(getEditURI());
        addAuthentication(method);
        try {
            getHttpClient().executeMethod(method);
        } catch (final IOException ex) {
            throw new ProponoException("ERROR: removing entry, HTTP code", ex);
        } finally {
            method.releaseConnection();
        }
    }
251436
public function actionDelete()
	{
		if(Yii::app()->request->isPostRequest)
		{
			// we only allow deletion via POST request
			$this->loadModel()->delete();

			// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
			if(!isset($_POST['ajax']))
				$this->redirect(array('index'));
		}
		else
			throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
	}
866458
private void postDelete(User user) throws Exception
   {
      for (UserEventListener listener : listeners)
      {
         listener.postDelete(user);
      }
   }
791674
public function deleteResource()
    {
        if (!$this->isXmlHttpRequest() || !$this->hasRequestParameter('id')) {
            throw new common_exception_BadRequest('wrong request mode');
        }

        $id = $this->getRequestParameter('id');

        // Csrf token validation
        $this->validateCsrf();
        $this->validateInstanceRoot($id);

        $this->signatureValidator->checkSignature(
            $this->getRequestParameter('signature'),
            $id
        );

        $resource = $this->getResource($this->getRequestParameter('id'));
        $deleted = $this->getClassService()->deleteResource($resource);
        return $this->returnJson(array(
            'deleted' => $deleted
        ));
    }
618736
function destroy(callback) {
            var model = this;
            var request = {
                action : 'remove',
                model : model.constructor,
                data : this
            };
            this.dispatch('beforeDestroy');

            this.constructor.storage.remove(request, function destroyCallback() {
                model.setProperty('id', null);
                model.dispatch('afterDestroy');
                if (callback) {
                    callback(model);
                }
            });
        }
909528
def delete_instance(self, instance, using_transactions=True, dry_run=False):
        
        self.before_delete_instance(instance, dry_run)
        if not using_transactions and dry_run:
            # we don't have transactions and we want to do a dry_run
            pass
        else:
            instance.delete()
        self.after_delete_instance(instance, dry_run)
48705
private void doDelete() throws PageException, SearchException {
	required("index", action, "collection", collection);
	if (type != SearchIndex.TYPE_CUSTOM) required("index", action, "key", key);

	// no type defined
	if (type == -1) {
	    if (query != null) {
		type = SearchIndex.TYPE_CUSTOM;
	    }
	    else {
		Resource file = null;
		try {
		    file = ResourceUtil.toResourceExisting(pageContext, key);
		    pageContext.getConfig().getSecurityManager().checkFileLocation(file);
		}
		catch (ExpressionException e) {}

		if (file != null && file.exists() && file.isFile()) type = SearchIndex.TYPE_FILE;
		else if (file != null && file.exists() && file.isDirectory()) type = SearchIndex.TYPE_PATH;
		else {
		    try {
			new URL(key);
			type = SearchIndex.TYPE_URL;
		    }
		    catch (MalformedURLException e) {}
		}
	    }
	}

	collection.deleteIndex(pageContext, key, type, query);
    }
372386
public void doRemove() throws DBException
    {
        super.doRemove();
        if (m_arrayCache != null)
            if (m_iLogicalIndex != -1)
                m_arrayCache.set(m_iLogicalIndex, null);    // Show the current record as deleted.
    }
1000790
def delete(self, request, *args, **kwargs):
        
        self.object = self.get_object()
        success_url = self.get_success_url()
        self.object.delete()

        if self.request.is_ajax():
            return JSONResponseMixin.render_to_response(self, context={})

        return HttpResponseRedirect(success_url)
359544
def _delete_example(self, request):
    
    index = int(request.args.get('index'))
    if index >= len(self.examples):
      return http_util.Respond(request, {'error': 'invalid index provided'},
                               'application/json', code=400)
    del self.examples[index]
    self.updated_example_indices = set([
        i if i < index else i - 1 for i in self.updated_example_indices])
    self.generate_sprite([ex.SerializeToString() for ex in self.examples])
    return http_util.Respond(request, {}, 'application/json')
1246643
def unbind(self, instance_id: str, binding_id: str, details: UnbindDetails):
        
        
        # Find the instance
        instance = self._backend.find(instance_id)
        
        # Find the binding
        binding = self._backend.find(binding_id, instance)
        if not binding.isProvisioned():
            # The binding does not exist
            raise ErrBindingDoesNotExist()
        
        # Delete the binding
        self._backend.unbind(binding)
607812
public void delete() throws SftpStatusException, SshException {
		if (sftp == null) {
			throw new SshException("Instance not connected to SFTP subsystem",
					SshException.BAD_API_USAGE);
		}

		if (isDirectory()) {
			sftp.removeDirectory(getAbsolutePath());
		} else {
			sftp.removeFile(getAbsolutePath());
		}
	}
1194271
public function deleteAll()
    {
        $response = [
            'success' => true,
            'deleted' => []
        ];
        if (!$this->isXmlHttpRequest()) {
            throw new common_exception_BadRequest('wrong request mode');
        }

        // Csrf token validation
        $this->validateCsrf();

        $ids = [];

        foreach ($this->getRequestParameter('ids') as $id) {
            $ids[] = $id['id'];
        }

        $this->signatureValidator->checkSignatures($this->getRequestParameter('ids'));

        $this->validateInstancesRoot($ids);

        foreach ($ids as $id) {
            $deleted = false;
            try {
                if ($this->hasWriteAccess($id)) {
                    $resource = new \core_kernel_classes_Resource($id);
                    if ($resource->isClass()) {
                        $deleted = $this->getClassService()->deleteClass(new \core_kernel_classes_Class($id));
                    } else {
                        $deleted = $this->getClassService()->deleteResource($resource);
                    }
                }
            } catch (\common_Exception $ce) {
                \common_Logger::w('Unable to remove resource ' . $id . ' : ' . $ce->getMessage());
            }
            if ($deleted) {
                $response['deleted'][] = $id;
            }
        }

        return $this->returnJson($response);
    }
1021401
def destroy(self, request, *args, **kwargs):
        
        obj = self.get_object()
        user = request.user

        if strtobool(request.query_params.get('delete_content', 'false')):
            for data in obj.data.all():
                if user.has_perm('edit_data', data):
                    data.delete()

            # If all data objects in an entity are removed, the entity may
            # have already been removed, so there is no need to call destroy.
            if not Entity.objects.filter(pk=obj.pk).exists():
                return Response(status=status.HTTP_204_NO_CONTENT)

        # NOTE: Collection's ``destroy`` method should be skiped, so we
        # intentionaly call it's parent.
        return super(CollectionViewSet, self).destroy(  # pylint: disable=no-member,bad-super-call
            request, *args, **kwargs
        )
136019
public function delete()
	{
		JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));

		// Get items to remove from the request.
		$cid = $this->input->get('cid', array(), 'array');
		$extension = $this->input->getCmd('extension', null);

		if (!is_array($cid) || count($cid) < 1)
		{
			JError::raiseWarning(500, JText::_($this->text_prefix . '_NO_ITEM_SELECTED'));
		}
		else
		{
			// Get the model.
			/** @var CategoriesModelCategory $model */
			$model = $this->getModel();

			// Make sure the item ids are integers
			$cid = ArrayHelper::toInteger($cid);

			// Remove the items.
			if ($model->delete($cid))
			{
				$this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid)));
			}
			else
			{
				$this->setMessage($model->getError());
			}
		}

		$this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&extension=' . $extension, false));
	}