Adds support for resource URIs for MongoHQ and Mongolab.

Old-style MONGODB_* configuration is left in place, but
Flask-PyMongo at least uses the MONGO_URI in preference.

At some point in the future, we should remove the MONGODB_*
selectors if it is possible to do so.
This commit is contained in:
Lyndsy Simon
2013-03-03 16:24:37 -06:00
parent d691e2b6d9
commit 6ec4245374
+2
View File
@@ -58,6 +58,7 @@ class Heroku(object):
mongolab_uri = environ.get('MONGOLAB_URI')
if mongolab_uri:
url = urlparse.urlparse(mongolab_uri)
app.config.setdefault('MONGO_URI', mongolab_uri)
app.config.setdefault('MONGODB_USER', url.username)
app.config.setdefault('MONGODB_PASSWORD', url.password)
app.config.setdefault('MONGODB_HOST', url.hostname)
@@ -68,6 +69,7 @@ class Heroku(object):
mongohq_uri = environ.get('MONGOHQ_URL')
if mongohq_uri:
url = urlparse.urlparse(mongohq_uri)
app.config.setdefault('MONGO_URI', mongohq_uri)
app.config.setdefault('MONGODB_USER', url.username)
app.config.setdefault('MONGODB_PASSWORD', url.password)
app.config.setdefault('MONGODB_HOST', url.hostname)