def create_dynamic_model(keyspace, classname, baseclass):
    """Create a dynamic ORM class with a custom keyspace/class/table.

    Given a keyspace, a camelcase class name, and a base class
    derived from Base, create a dynamic model that adopts a
    table name based on a lower-cased version of the class name,
    then create the table in the keyspace if it doesn't already exist.
    If the baseclass already has __tablename__ or __keyspace__ set, those
    will take precedence. Set those to None to use keyspace/classname here.
    """

    # The comma after baseclass belongs there! Tuple of length 1.
    model = type(
        classname, (baseclass,), {
            '__tablename__': baseclass.__tablename__ or classname.lower(),
            '__keyspace__': baseclass.__keyspace__ or keyspace})
    model.table_create()
    return model