'Updates the super-entity links of an instance record
@param table: the instance table
@param record: the instance record'

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

    get_config = cls.get_config
    tablename = table._tablename
    supertables = get_config(tablename, 'super_entity')
    if (not supertables):
        return False
    record_id = record.get('id', None)
    if (not record_id):
        return False
    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))
    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)
        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:
            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:
            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)
    if super_keys:
        db((table.id == record_id)).update(**super_keys)
    record.update(super_keys)
    return True
