Skip to content

Commit

Permalink
Fixed reskit dependency (see restkit/pool/simple.py@a2a63a07).
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Plum committed Jan 7, 2011
1 parent 45d75da commit e33f46c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions flaskext/couchdbkit.py
Expand Up @@ -13,7 +13,7 @@
import couchdbkit
from couchdbkit import Server
from couchdbkit.loaders import FileSystemDocsLoader
from restkit.pool.simple import SimplePool
from restkit.conn import TConnectionManager


__all__ = ['CouchDBKit']
Expand All @@ -33,30 +33,30 @@ def _include_couchdbkit(obj):
class CouchDBKit(object):
"""This class is used to control CouchDB integration to a Flask
application.
:param app: The application to bind this CouchDBKit instance into.
"""

def __init__(self, app):
app.config.setdefault('COUCHDB_SERVER', 'http://localhost:5984/')
app.config.setdefault('COUCHDB_DATABASE', None)
app.config.setdefault('COUCHDB_KEEPALIVE', None)
app.config.setdefault('COUCHDB_VIEWS', '_design')

server_uri = app.config.get('COUCHDB_SERVER')
pool_keepalive = app.config.get('COUCHDB_KEEPALIVE')
if pool_keepalive is not None:
pool = SimplePool(keepalive=pool_keepalive)
pool = TConnectionManager(keepalive=pool_keepalive)
server = Server(server_uri, pool_instance=pool)
else:
server = Server(server_uri)

self.app = app
self.server = server

_include_couchdbkit(self)
self.init_db()

def init_db(self):
"""Initialize database object from the `COUCHDB_DATABASE`
configuration variable. If the database does not already exists,
Expand All @@ -65,7 +65,7 @@ def init_db(self):
dbname = self.app.config.get('COUCHDB_DATABASE')
self.db = self.server.get_or_create_db(dbname)
self.Document._db = self.db

def sync(self):
"""Sync the local views with CouchDB server."""
local_path = self.app.config.get('COUCHDB_VIEWS')
Expand Down

0 comments on commit e33f46c

Please sign in to comment.