def create_model_offline(schema, collection_factory, class_name):
    """
    Entry point for creating a new Mongothon model without instantiating
    a database connection. The collection is instead provided through a closure
    that is resolved upon the model's first database access.
    """
    model_class = type(class_name,
                       (Model,),
                       dict(schema=schema, _collection_factory=staticmethod(collection_factory)))

    # Since we are dynamically creating this class here, we modify __module__ on the
    # created class to point back to the module from which `create_model_offline` was called
    model_class.__module__ = _module_name_from_previous_frame(1)

    return model_class
Entry point for creating a new Mongothon model without instantiating
    a database connection. The collection is instead provided through a closure
    that is resolved upon the model's first database access.