Move "connect to database" into db/util.py

This commit is contained in:
Elrond
2011-05-18 01:03:40 +02:00
parent 0f18ed8f5e
commit a4bae8700e
2 changed files with 13 additions and 6 deletions

11
mediagoblin/db/util.py Normal file
View File

@@ -0,0 +1,11 @@
import mongokit
def connect_database(app_config):
"""Connect to the main database, take config from app_config"""
port = app_config.get('db_port')
if port:
port = asint(port)
connection = mongokit.Connection(
app_config.get('db_host'), port)
return connection