Esempio n. 1
0
def get_by_id_old(id, db=None):
    if db is None:
        db = get_file_db()
    first = db.select_first(where=dict(id=id))
    if first is not None:
        return build_note(first)
    return None
Esempio n. 2
0
def update_note_content(id, content, data=''):
    if id is None:
        return
    if content is None:
        content = ''
    if data is None:
        data = ''
    db = xtables.get_note_content_table()
    result = db.select_first(where=dict(id=id))
    if result is None:
        db.insert(id=id, content=content, data=data)
    else:
        db.update(where=dict(id=id), content=content, data=data)
Esempio n. 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_first(what="id,name,type,creator",
                                   where=dict(id=file.parent_id))
    return pathlist
Esempio n. 4
0
def list_path_old(file, limit=2, db=None):
    if db is None:
        db = xtables.get_file_table()
    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_first(what="id,name,type,creator",
                                   where=dict(id=file.parent_id))
    return pathlist
Esempio n. 5
0
def query_note_name(id):
    db = xtables.get_note_table()
    result = db.select_first(what="name", where=dict(id=id))
    if result:
        return result.name
    return None
Esempio n. 6
0
def query_note_conent(id):
    db = xtables.get_note_content_table()
    result = db.select_first(where=dict(id=id))
    if result is None:
        return None, None
    return result.get("content", ""), result.get("data", "")