MongoEngine/mongoengine — pull request #483 by grampajoe (2013-10-04 18:43:43+00:00)
Title: Use defaults when host and port are passed as None

Currently, there are a few alternatives for specifying the host and port when connecting. Because of the way the defaults are given in `register_connection`, none of them are very nice.

You can always use the internal defaults. This should only work for development environments:
```python
mongoengine.connect('connection_alias', 'db_name')
```

You can override the defaults explicitly, in which case you have to provide your own (redundant) defaults:
```python
host = os.environ.get('MONGO_HOST', 'localhost')
port = os.environ.get('MONGO_PORT', 27017)
mongoengine.connect('connection_alias', 'db_name', host=host, port=port)
```

This one's really ugly, but you *could* use an if statement:
```python
host = os.environ.get('MONGO_HOST')
port = os.environ.get('MONGO_PORT')
if host and port:
mongoengine.connect('connection_alias', 'db_name', host=host, port=port)
else:
mongoengine.connect('connection_alias', 'db_name')
```

To make this nicer, this pull request adds the ability to pass `None` for `host` and `port` to fall back to MongoEngine's internal defaults:
```python
host = os.environ.get('MONGO_HOST')
port = os.environ.get('MONGO_PORT')
mongoengine.connect('connection_alias', 'db_name', host=host, port=port)
```
:tada: