hmarr/mongoengine — Issue #453: ReplicaSetConnection doesn't take a 'host' argument
Author: jpeddicord
Created: 2012-03-05 15:43:50+00:00
State: open

Was anxious to try out 0.6 today, but unfortunately it looks like there's a little issue with how replica sets are handled.

Near line 111 in connection.py, there is:

```python
if 'replicaSet' in conn_settings:
connection_class = ReplicaSetConnection
```

However, ReplicaSetConnection [takes a hosts\_or\_uri parameter instead of hosts](http://api.mongodb.org/python/current/api/pymongo/replica_set_connection.html). This results in:

mongoengine.connection.ConnectionError: Cannot connect to database db :
Unknown option host

A quick fix I used was to replace the argument:

```python
if 'replicaSet' in conn_settings:
conn_settings['hosts_or_uri'] = conn_settings.pop('host', None)
connection_class = ReplicaSetConnection
```

There might be something cleaner than that, but it at least got it working for me.