'Runs the onvalidation routine for this table, and maps
form fields and errors to regular keys
@param tablename: the table name
@param form: the FORM'

@classmethod
def onvalidation(cls, tablename, form):

    (ORIGINAL, DUPLICATE, KEEP) = (cls.ORIGINAL, cls.DUPLICATE, cls.KEEP)
    if form.vars[KEEP.d]:
        prefix = ('%s_' % DUPLICATE)
    else:
        prefix = ('%s_' % ORIGINAL)
    data = Storage()
    for key in form.vars:
        if key.startswith(prefix):
            fname = key.split('_', 1)[1]
            data[fname] = form.vars[key]
    errors = current.s3db.onvalidation(tablename, data, method='update')
    if errors:
        for fname in errors:
            form.errors[('%s%s' % (prefix, fname))] = errors[fname]
    return
