@classmethod
    def delete_super(cls, table, record):

        # Must have a record ID
        record_id = record.get(table._id.name, None)
        if not record_id:
            raise RuntimeError("Record ID required for delete_super")

        # Get all super-tables
        get_config = cls.get_config
        supertables = get_config(table._tablename, "super_entity")

        # None? Ok - done!
        if not supertables:
            return True
        if not isinstance(supertables, (list, tuple)):
            supertables = [supertables]

        # Get the keys for all super-tables
        keys = {}
        load = {}
        for sname in supertables:
            stable = cls.table(sname) if isinstance(sname, str) else sname
            if stable is None:
                continue
            key = stable._id.name
            if key in record:
                keys[stable._tablename] = (key, record[key])
            else:
                load[stable._tablename] = key

        # If necessary, load missing keys
        if load:
            row = current.db(table._id == record_id).select(
                    table._id, *load.values(), limitby=(0, 1)).first()
            for sname, key in load.items():
                keys[sname] = (key, row[key])

        # Delete super-records
        define_resource = current.s3db.resource
        update_record = record.update_record
        for sname in keys:
            key, value = keys[sname]
            if not value:
                # Skip if we don't have a super-key
                continue

            # Remove the super key
            update_record(**{key: None})

            # Delete the super record
            sresource = define_resource(sname, id=value)
            sresource.delete(cascade=True)

            if sresource.error:
                # Restore the super key
                # @todo: is this really necessary? => caller must roll back
                #        anyway in this case, which would automatically restore
                update_record(**{key: value})
                return False

        return True

    # -------------------------------------------------------------------------
Removes the super-entity links of an instance record
dataset/ETHPy150Open sahana/eden/modules/s3/s3model.py/S3Model.delete_super