pymongo.Connection also provides a replicaSet param to identify the replication set name, this method seems will make the minimum change in code
pymongo.Connection also provides a replicaSet param to identify the replication set name, this method seems will make the minimum change in code