def init_model(connection):
    """Call me before using any of the tables or classes in the model."""
    raw_db = getattr(connection, config.get('mongodb.db', 'anygit'))
    db = getattr(connection, config.get('mongodb.db', 'anygit'))
    # Transform
    db.add_son_manipulator(TransformObject())

    for obj in globals().itervalues():
        if type(obj) == type and issubclass(obj, MongoDbModel) and hasattr(obj, '__tablename__'):
            save_classes.append(obj)
            tablename = getattr(obj, '__tablename__')
            obj._object_store = getattr(db, tablename)
            obj._raw_object_store = getattr(raw_db, tablename)
            collection_to_class[obj._object_store] = obj
dataset/ETHPy150Open ebroder/anygit/anygit/backends/mongodb.py/init_model/original