Permalink
Browse files

fix mongo storage backend

  • Loading branch information...
1 parent df1fad8 commit dd7ef073f820ae8e1be064a04da0bbf333f45e2f Geoffrey Lehée committed Mar 23, 2013
Showing with 12 additions and 14 deletions.
  1. +3 −1 heroku.sh
  2. +7 −10 leselys/backends/storage/_mongodb.py
  3. +2 −3 scripts/leselys
View
@@ -1,6 +1,7 @@
#!/bin/bash
# Create heroku configuration file
+DATABASE=$(echo ${MONGOHQ_URL} | cut -d"/" -f4)
cat >heroku.ini <<EOL
[webserver]
host = 0.0.0.0
@@ -9,7 +10,8 @@ debug = false
[storage]
type = mongodb
-uri = ${MONGOHQ_URL}
+host = ${MONGOHQ_URL}
+database = ${DATABASE}
[session]
type = redis
@@ -2,22 +2,19 @@
import sys
from pymongo import MongoClient
-from pymongo.uri_parser import parse_uri
from bson.objectid import ObjectId
from _storage import Storage
class Mongodb(Storage):
def __init__(self, **kwargs):
- if not kwargs.get('uri'):
- print('Mongodb storage backend need uri option')
- sys.exit(1)
- self.uri = parse_uri(kwargs.get('uri'))
-
- self.host = self.uri['nodelist'][0][0]
- self.port = int(self.uri['nodelist'][0][1])
- self.connection = MongoClient(self.host, self.port, **self.uri['options'])
- self.db = self.connection[self.uri['database']]
+ self.database = kwargs.get('database') or 'leselys'
+
+ if kwargs.get('database'):
+ del kwargs['database']
+ self.connection = MongoClient(**kwargs)
+
+ self.db = self.connection[self.database]
def get_users(self):
res = []
View
@@ -46,16 +46,15 @@ debug = false
[storage]
type = mongodb
-database = mongodb://localhost:27017/leselys
-mode = multi
+host = mongodb://localhost:27017
+database = leselys
[worker]
broker = mongodb://localhost:27017/leselys
interval = 10 # In minutes
[session]
type = memory
-
#type = redis
#host = localhost
#port = 6379

0 comments on commit dd7ef07

Please sign in to comment.