Mercurial > hg > Feedworm
comparison backend/couchdb/CouchDbBackend.py @ 180:a4832a180c69
allow setting the URL to the database via command line
author | dirk |
---|---|
date | Sat, 10 Sep 2011 04:43:40 +0200 |
parents | 7001070d0bd5 |
children | 1ab48428e2f9 |
comparison
equal
deleted
inserted
replaced
179:c8393c2cd324 | 180:a4832a180c69 |
---|---|
13 Backend that uses CouchDB for persistence | 13 Backend that uses CouchDB for persistence |
14 ''' | 14 ''' |
15 | 15 |
16 def __init__(self): | 16 def __init__(self): |
17 CouchDb.init() | 17 CouchDb.init() |
18 server = couchdb.Server() | 18 server = self._initServer() |
19 self.database = server[CouchDb.database] | 19 self.database = server[CouchDb.database] |
20 self.prefs = None | 20 self.prefs = None |
21 | |
22 def _initServer(self): | |
23 if CouchDb.database_url is not None: | |
24 return couchdb.Server(CouchDb.database_url) | |
25 else: | |
26 return couchdb.Server() | |
21 | 27 |
22 def preferences(self): | 28 def preferences(self): |
23 if self.prefs is None: | 29 if self.prefs is None: |
24 self.prefs = Preferences(self.database) | 30 self.prefs = Preferences(self.database) |
25 return self.prefs | 31 return self.prefs |