'Create a new link in a link table if it doesn\'t yet exist.
This function is meant to also update links in "embed"
actuation mode once this gets implemented, therefore the
method name "update_link".
@param master: the master record
@param record: the new component record to be linked'

def update_link(self, master, record):

    if ((self.parent is None) or (self.linked is None)):
        return None
    resource = self.linked
    pkey = resource.pkey
    lkey = resource.lkey
    rkey = resource.rkey
    fkey = resource.fkey
    if (pkey not in master):
        return None
    _lkey = master[pkey]
    if (fkey not in record):
        return None
    _rkey = record[fkey]
    if ((not _lkey) or (not _rkey)):
        return None
    ltable = self.table
    ltn = ltable._tablename
    query = ((ltable[lkey] == _lkey) & (ltable[rkey] == _rkey))
    row = current.db(query).select(ltable._id, limitby=(0, 1)).first()
    if (not row):
        s3db = current.s3db
        onaccept = s3db.get_config(ltn, 'create_onaccept')
        if (onaccept is None):
            onaccept = s3db.get_config(ltn, 'onaccept')
        data = {lkey: _lkey, rkey: _rkey}
        link_id = ltable.insert(**data)
        data[ltable._id.name] = link_id
        s3db.update_super(ltable, data)
        if (link_id and onaccept):
            callback(onaccept, Storage(vars=Storage(data)))
    else:
        link_id = row[ltable._id.name]
    return link_id
