'Instantiate a dynamic Table
@param tablename: the table name
@return: a Table instance'

def define_table(self, tablename):

    db = current.db
    redefine = (tablename in db)
    s3db = current.s3db
    ttable = s3db.s3_table
    ftable = s3db.s3_field
    query = (((ttable.name == tablename) & (ttable.deleted != True)) & (ftable.table_id == ttable.id))
    rows = db(query).select(ftable.name, ftable.field_type, ftable.label, ftable.require_unique, ftable.require_not_empty, ftable.options, ftable.default_value, ftable.settings, ftable.comments)
    if (not rows):
        return None
    fields = []
    for row in rows:
        field = self._field(tablename, row)
        if field:
            fields.append(field)
    from s3fields import s3_meta_fields
    fields.extend(s3_meta_fields())
    if fields:
        migrate_enabled = db._migrate_enabled
        db._migrate_enabled = True
        db.define_table(tablename, migrate=True, redefine=redefine, *fields)
        table = db[tablename]
        db._migrate_enabled = migrate_enabled
        self._configure(tablename)
        return table
    else:
        return None
