@classmethod
    def _dl_ajax_delete(cls, r, resource):

        UID = current.xml.UID

        delete = r.get_vars.get("delete", None)
        if delete is not None:

            dresource = current.s3db.resource(resource, id=delete)

            # Deleting in this resource allowed at all?
            deletable = dresource.get_config("deletable", True)
            if not deletable:
                r.error(403, current.ERROR.NOT_PERMITTED)

            # Permitted to delete this record?
            authorised = current.auth.s3_has_permission("delete",
                                                        dresource.table,
                                                        record_id=delete)
            if not authorised:
                r.unauthorised()

            # Delete it
            uid = None
            if UID in dresource.table:
                rows = dresource.select([UID],
                                        start=0,
                                        limit=1,
                                        as_rows=True)
                if rows:
                    uid = rows[0][UID]
            numrows = dresource.delete(format=r.representation)
            if numrows > 1:
                message = "%s %s" % (numrows,
                                     current.T("records deleted"))
            elif numrows == 1:
                message = cls.crud_string(dresource.tablename,
                                          "msg_record_deleted")
            else:
                r.error(404, dresource.error)

            # Return a JSON message
            # @note: make sure the view doesn't get overridden afterwards!
            current.response.view = "xml.html"
            return current.xml.json_message(message=message, uuid=uid)
        else:
            r.error(404, current.ERROR.BAD_RECORD)

    # -------------------------------------------------------------------------
dataset/ETHPy150Open sahana/eden/modules/s3/s3crud.py/S3CRUD._dl_ajax_delete/original