def get_children(C, tid): from couchdb import Task qry = "select t.* from task_hierarchy th,tasks t where %s=any(th.path_info) and th.id<>%s and t.id=th.id" opts = (tid, tid) C.execute(qry, opts) rows = [t['contents'] for t in C.fetchall()] rt = [] for r in rows: r['created_at'] = datetime.strptime( r['created_at'].split('.')[0].split('Z')[0], "%Y-%m-%dT%H:%M:%S") t = Task(**r) rt.append(t) return rt
def get_task(C, tid): from couchdb import Task C.execute("select contents from tasks where id=%s", (tid, )) c = C.fetchall()[0]['contents'] return Task(**c)