|
|
@ -10,17 +10,17 @@ import json
|
|
|
|
from common import Reader,Writer
|
|
|
|
from common import Reader,Writer
|
|
|
|
class Couch:
|
|
|
|
class Couch:
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
This class is a wrapper for read/write against couchdb. The class captures common operations for read/write.
|
|
|
|
@param url host & port reference
|
|
|
|
@param url host & port reference
|
|
|
|
@param uid user id involved
|
|
|
|
@param doc user id involved
|
|
|
|
|
|
|
|
|
|
|
|
@param dbname database name (target)
|
|
|
|
@param dbname database name (target)
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
def __init__(self,**args):
|
|
|
|
def __init__(self,**args):
|
|
|
|
url = args['url']
|
|
|
|
url = args['url']
|
|
|
|
self.uid = args['uid']
|
|
|
|
self.uid = args['doc']
|
|
|
|
dbname = args['dbname']
|
|
|
|
dbname = args['dbname']
|
|
|
|
if 'username' not in args and 'password' not in args :
|
|
|
|
if 'username' not in args and 'password' not in args :
|
|
|
|
self.server = cloudant.CouchDB(url=url)
|
|
|
|
self.server = cloudant.CouchDB(None,None,url=url)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.server = cloudant.CouchDB(args['username'],args['password'],url=url)
|
|
|
|
self.server = cloudant.CouchDB(args['username'],args['password'],url=url)
|
|
|
|
self.server.connect()
|
|
|
|
self.server.connect()
|
|
|
@ -56,10 +56,10 @@ class Couch:
|
|
|
|
|
|
|
|
|
|
|
|
def view(self,**args):
|
|
|
|
def view(self,**args):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
We are executing a view
|
|
|
|
The function will execute a view (provivded a user is authenticated)
|
|
|
|
:id design document _design/xxxx (provide full name with _design prefix)
|
|
|
|
:id design document _design/xxxx (provide full name with _design prefix)
|
|
|
|
:view_name name of the view i.e
|
|
|
|
:view_name name of the view i.e
|
|
|
|
:key key to be used to filter the content
|
|
|
|
:key(s) key(s) to be used to filter the content
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
document = cloudant.design_document.DesignDocument(self.dbase,args['id'])
|
|
|
|
document = cloudant.design_document.DesignDocument(self.dbase,args['id'])
|
|
|
|
document.fetch()
|
|
|
|
document.fetch()
|
|
|
|