'On-accept routine for s3_field:
- set master table name for component keys (from field type)'

@staticmethod
def s3_field_onaccept(form):

    form_vars = form.vars
    try:
        record_id = form_vars.id
    except AttributeError:
        return
    db = current.db
    table = db.s3_field
    row = db((table.id == record_id)).select(table.id, table.component_key, table.field_type, limitby=(0, 1)).first()
    master = None
    if (row and row.component_key):
        field_type = str(row.field_type)
        if (field_type[:10] == 'reference    '):
            ktablename = field_type.split('    ', 1)[1]
            if ('.' in ktablename):
                ktablename = ktablename.split('.', 1)[0]
            master = ktablename
    row.update_record(master=master)
