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

        get_config = cls.get_config

        # Get all super-entities of this table
        tablename = table._tablename
        supertables = get_config(tablename, "super_entity")
        if not supertables:
            return False

        # Get the record
        record_id = record.get("id", None)
        if not record_id:
            return False

        # Find all super-tables, super-keys and shared fields
        if not isinstance(supertables, (list, tuple)):
            supertables = [supertables]
        updates = []
        fields = []
        has_deleted = "deleted" in table.fields
        has_uuid = "uuid" in table.fields
        for s in supertables:
            if type(s) is not Table:
                s = cls.table(s)
            if s is None:
                continue
            tn = s._tablename
            key = cls.super_key(s)
            shared = get_config(tablename, "%s_fields" % tn)
            if not shared:
                shared = dict((fn, fn)
                              for fn in s.fields
                              if fn != key and fn in table.fields)
            else:
                shared = dict((fn, shared[fn])
                              for fn in shared
                              if fn != key and \
                                 fn in s.fields and \
                                 shared[fn] in table.fields)
            fields.extend(shared.values())
            fields.append(key)
            updates.append((tn, s, key, shared))

        # Get the record data
        db = current.db
        if has_deleted:
            fields.append("deleted")
        if has_uuid:
            fields.append("uuid")
        fields = [ogetattr(table, fn) for fn in list(set(fields))]
        _record = db(table.id == record_id).select(limitby=(0, 1),
                                                   *fields).first()
        if not _record:
            return False

        super_keys = Storage()
        for tn, s, key, shared in updates:
            data = Storage([(fn, _record[shared[fn]]) for fn in shared])
            data.instance_type = tablename
            if has_deleted:
                data.deleted = _record.get("deleted", False)
            if has_uuid:
                data.uuid = _record.get("uuid", None)

            # Do we already have a super-record?
            skey = ogetattr(_record, key)
            if skey:
                query = (s[key] == skey)
                row = db(query).select(s._id, limitby=(0, 1)).first()
            else:
                row = None

            if row:
                # Update the super-entity record
                db(s._id == skey).update(**data)
                super_keys[key] = skey
                data[key] = skey
                form = Storage(vars=data)
                onaccept = get_config(tn, "update_onaccept",
                           get_config(tn, "onaccept", None))
                if onaccept:
                    onaccept(form)
            else:
                # Insert a new super-entity record
                k = s.insert(**data)
                if k:
                    super_keys[key] = k
                    data[key] = k
                    onaccept = get_config(tn, "create_onaccept",
                               get_config(tn, "onaccept", None))
                    if onaccept:
                        form = Storage(vars=data)
                        onaccept(form)

        # Update the super_keys in the record
        if super_keys:
            db(table.id == record_id).update(**super_keys)

        record.update(super_keys)
        return True

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