'Create a link table entry for a new node
@param link: the link information (as returned from
preprocess_create_node)
@param node: the new node'

def postprocess_create_node(self, link, node):

    try:
        node_id = node[self.pkey.name]
    except (AttributeError, KeyError):
        return
    s3db = current.s3db
    tablename = link['linktable']
    linktable = s3db.table(tablename)
    if (not linktable):
        return
    lkey = link['lkey']
    rkey = link['rkey']
    data = {rkey: link['parent_id'], lkey: node_id}
    query = ((linktable[lkey] == data[lkey]) & (linktable[rkey] == data[rkey]))
    row = current.db(query).select(linktable._id, limitby=(0, 1)).first()
    if (not row):
        onaccept = s3db.get_config(tablename, 'create_onaccept')
        if (onaccept is None):
            onaccept = s3db.get_config(tablename, 'onaccept')
        link_id = linktable.insert(**data)
        data[linktable._id.name] = link_id
        s3db.update_super(linktable, data)
        if (link_id and onaccept):
            callback(onaccept, Storage(vars=Storage(data)))
    return
