'Reference field constructor
@param tablename: the table name
@param row: the s3_field Row
@return: the Field instance'

@staticmethod
def _reference_field(tablename, row):

    fieldname = row.name
    fieldtype = row.field_type
    ktablename = fieldtype.split('    ', 1)[1].split('.', 1)[0]
    ktable = current.s3db.table(ktablename)
    if ktable:
        from s3fields import S3Represent
        from s3validators import IS_ONE_OF
        if ('name' in ktable.fields):
            represent = S3Represent(lookup=ktablename, translate=True)
        else:
            represent = None
        requires = IS_ONE_OF(current.db, str(ktable._id), represent)
        field = Field(fieldname, fieldtype, represent=represent, requires=requires)
    else:
        field = None
    return field
