예제 #1
0
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
예제 #2
0
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
예제 #3
0
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
예제 #4
0
 def GET(self):
     id = xutils.get_argument("id", type=int)
     db = xtables.get_file_table()
     return db.select_one(where={"id": id})