Skip to content

Commit

Permalink
Wrap the Database.info result to a TrombiDict
Browse files Browse the repository at this point in the history
  • Loading branch information
Petri Lehtinen committed May 4, 2011
1 parent a736187 commit 6f1501e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions test/test_client.py
Expand Up @@ -260,6 +260,7 @@ def get_info(db):
db.info(check_info) db.info(check_info)


def check_info(info): def check_info(info):
eq(info.error, False)
eq(info['db_name'], 'testdb') eq(info['db_name'], 'testdb')
eq(info['doc_count'], 0) eq(info['doc_count'], 0)
assert 'update_seq' in info assert 'update_seq' in info
Expand Down
9 changes: 8 additions & 1 deletion trombi/client.py
Expand Up @@ -99,6 +99,13 @@ def __init__(self, data):
super(TrombiResult, self).__init__() super(TrombiResult, self).__init__()




class TrombiDict(dict):
error = False

def to_basetype(self):
return dict(self)


def _jsonize_params(params): def _jsonize_params(params):
result = dict() result = dict()
for key, value in params.iteritems(): for key, value in params.iteritems():
Expand Down Expand Up @@ -257,7 +264,7 @@ def _fetch(self, url, *args, **kwargs):
def info(self, callback): def info(self, callback):
def _really_callback(response): def _really_callback(response):
if response.code == 200: if response.code == 200:
callback(json.loads(response.body)) callback(TrombiDict(json.loads(response.body)))
else: else:
callback(_error_response(response)) callback(_error_response(response))


Expand Down

0 comments on commit 6f1501e

Please sign in to comment.