mirror of
https://github.com/kennethreitz/flask-heroku.git
synced 2026-06-05 23:10:17 +00:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user