def get_by_id(id, db=None): if db is None: db = get_file_db() first = db.select_one(where=dict(id=id)) if first is not None: return FileDO.fromDict(first) return None
def get_pathlist(db, file): pathlist = [] # TODO LIMIT while file is not None: file.url = "/file/view?id=%s" % file.id pathlist.insert(0, file) if file.parent_id == 0: break else: file = db.select_one(where=dict(id=file.parent_id)) return pathlist
def get_pathlist(db, file, limit=2): pathlist = [] while file is not None: pathlist.insert(0, file) file.url = "/note/view?id=%s" % file.id if len(pathlist) >= limit: break if file.parent_id == 0: break else: file = db.select_one(where=dict(id=file.parent_id)) return pathlist
def GET(self): id = xutils.get_argument("id", type=int) db = xtables.get_file_table() return db.select_one(where={"id": id})