couchdbadapter.py (906B)
1 # standard imports 2 import copy 3 import json 4 import uuid 5 6 # third party imports 7 import pycouchdb 8 9 class couchdbadapter: 10 11 def __init__(self, username, password, database='feedwarrior', host='localhost', port=5984, ssl=False): 12 scheme = 'http' 13 if ssl: 14 scheme += 's' 15 dsn = '{}://{}:{}@{}:{}'.format(scheme, username, password, host, port) 16 self.server = pycouchdb.Server(dsn) 17 self.database = self.server.database(database) 18 self.dsn = dsn 19 self.username = username 20 self.password = password 21 22 23 def put(self, uu, entry, **kwargs): 24 e = entry.serialize() 25 e.pop('uuid') 26 e['_id'] =uu.hex 27 self.database.save(e) 28 29 30 def get(self, uu, **kwargs): 31 e = self.database.get(uu.hex) 32 # reverse parsing this is going to take a bit of effort 33 print('entry ZZZZZZZZZZZZZZZZZZZZZZZZz', e)