示例#1
0
def index():
    now = datetime.datetime.now()
    nowtime = now.strftime("%Y-%m-%d %H:%M:%S")
    if request.method != "POST":
        return ""
    if "password" not in request.form:
        return ""
    if request.form["password"] != password:
        return ""
    if "success" not in request.form:
        d = collections.OrderedDict()
        x = db.select("info", where="flag=0")
        if len(x) != 0:
            for key in x:
                d[key.msgid] = key.con
                db.insert("log", msgid=key.msgid, time=nowtime, state="send")
            return json.dumps(d)
        else:
            return ""
    else:
        msgid = request.form["success"]
        if msgid.isdigit():
            try:
                db.update("info", where="msgid=$msgid", flag=1, vars=locals())
                db.insert("log", msgid=msgid, time=nowtime, state="receive")
            except:
                pass
        return ""
示例#2
0
def index():
    now = datetime.datetime.now()
    nowtime = now.strftime('%Y-%m-%d %H:%M:%S')
    if request.method != 'POST':
        return ""
    if 'password' not in request.form:
        return ""
    if request.form['password'] != password:
        return ""
    if 'success' not in request.form:
        d = collections.OrderedDict()
        x = db.select('info', where="flag=0")
        if len(x) != 0:
            for key in x:
                d[key.msgid] = key.con
                db.insert("log", msgid=key.msgid, time=nowtime, state="send")
            return json.dumps(d)
        else:
            return ""
    else:
        msgid = request.form['success']
        if msgid.isdigit():
            try:
                db.update('info', where='msgid=$msgid', flag=1, vars=locals())
                db.insert("log", msgid=msgid, time=nowtime, state="receive")
            except:
                pass
        return ""
示例#3
0
文件: dao-old.py 项目: dudefu/xnote
def batch_query_sqlite(id_list):
    db = xtables.get_note_table()
    result = db.select(where="id IN $id_list", vars=dict(id_list=id_list))
    dict_result = dict()
    for item in result:
        dict_result[item.id] = item
    return dict_result
示例#4
0
文件: dao-old.py 项目: dudefu/xnote
def rdb_list_recent_edit(parent_id=None, offset=0, limit=None):
    if limit is None:
        limit = xconfig.PAGE_SIZE
    db = xtables.get_file_table()
    creator = xauth.get_current_name()
    if creator:
        where = "is_deleted = 0 AND (creator = $creator) AND type != 'group'"
    else:
        # 未登录
        where = "is_deleted = 0 AND is_public = 1 AND type != 'group'"

    cache_key = "[%s]note.recent$%s$%s" % (creator, offset, limit)
    files = cacheutil.get(cache_key)
    if files is None:
        files = list(
            db.select(
                what=
                "name, id, parent_id, ctime, mtime, type, creator, priority",
                where=where,
                vars=dict(creator=creator),
                order="priority DESC, mtime DESC",
                offset=offset,
                limit=limit))
        fill_parent_name(files)
        cacheutil.set(cache_key, files, expire=600)
    return files
示例#5
0
文件: dao.py 项目: zenistzw/xnote
def list_recent_edit(parent_id=None, offset=0, limit=None):
    if limit is None:
        limit = xconfig.PAGE_SIZE
    db = xtables.get_file_table()
    t = Timer()
    t.start()
    creator = xauth.get_current_name()
    if creator:
        where = "is_deleted = 0 AND (creator = $creator) AND type != 'group'"
    else:
        # 未登录
        where = "is_deleted = 0 AND is_public = 1 AND type != 'group'"

    cache_key = "[%s]note.recent$%s$%s" % (creator, offset, limit)
    files = cacheutil.get(cache_key)
    if files is None:
        files = list(
            db.select(
                what=
                "name, id, parent_id, ctime, mtime, type, creator, priority",
                where=where,
                vars=dict(creator=creator),
                order="priority DESC, mtime DESC",
                offset=offset,
                limit=limit))
        for item in files:
            item.parent_name = query_note_name(item.parent_id)
        cacheutil.set(cache_key, files, expire=600)
    t.stop()
    xutils.trace("NoteDao.ListRecentEdit", "", t.cost_millis())
    return files
示例#6
0
def list_recent_created(parent_id=None, limit=10):
    where = "is_deleted = 0 AND (creator = $creator OR is_public = 1)"
    if parent_id != None:
        where += " AND parent_id = %s" % parent_id
    db = xtables.get_file_table()
    return list(
        db.select(where=where,
                  vars=dict(creator=xauth.get_current_name()),
                  order="ctime DESC",
                  limit=limit))
示例#7
0
文件: dao-old.py 项目: dudefu/xnote
def rdb_list_note(creator, parent_id, offset, limit):
    db = xtables.get_note_table()
    where_sql = "parent_id=$parent_id AND is_deleted=0 AND (creator=$creator OR is_public=1)"
    files = db.select(where=where_sql,
                      vars=dict(parent_id=parent_id,
                                is_deleted=0,
                                creator=creator),
                      order="name",
                      limit=limit,
                      offset=offset)
    return files
示例#8
0
def suibiankankan(username):
    #Generate username related products. If none, return 5 random products
    owner_products = db.select('shareit', what = 'product_id, product_details', where = 'product_owner = $usrname', vars = dict(usrname = username)).list()
    user_products = db.select('shareit', what = 'product_id, product_details', where = 'product_user = $usrname', vars = dict(usrname = username)).list()
    strtmp = ''
    if len(owner_products) == 0 and len(user_products) == 0:
        #No user-related info, just randomly select 5 product details to show
        strtmp = u'随机展示5个产品:'
        random_products = db.select('shareit', what = 'product_details', limit = 5).list()
        for product in random_products:
            strtmp = strtmp + product.product_details + u';'
        return strtmp.strip(';')
    else:
        strtmp = u'你有所有权的产品:'
        for product in owner_products:
            strtmp = strtmp + u' [' + str(product.product_id) + u']' + product.product_details + u';'
        strtmp = strtmp.strip(';')
        strtmp = strtmp + u' \n你有使用权的产品:'
        for product in user_products:
            strtmp = strtmp + u' [' + str(product.product_id) + u']' + product.product_details + u';'
        return strtmp.strip(';')
示例#9
0
def wuchu(username, product_id, checkcode):
    #Check checkcode, and if ok, update the product information
    results = db.select('shareit', what = 'product_user, checkcode_user, product_details', where = 'product_id = $pro_id', vars = dict(pro_id = product_id)).list()[0]
    real_checkcode_username = results.checkcode_user
    original_user = results.product_user
   
    #raise NameError(real_checkcode_username)
    real_checkcode, wuru_username = str(real_checkcode_username).split('_', 1)
    
    if real_checkcode != checkcode or original_user != username:
        #Validation fail
        raise NameError(real_checkcode)
    else:
        db.update('shareit', where = 'product_id = $pro_id', vars = dict(pro_id = product_id), product_user = wuru_username, checkcode_user = '******')
        return results.product_details
示例#10
0
文件: dao.py 项目: zenistzw/xnote
def list_recent_viewed(creator=None, offset=0, limit=10):
    t = Timer()
    t.start()
    where = "is_deleted = 0 AND (creator = $creator)"
    db = xtables.get_file_table()
    result = list(
        db.select(where=where,
                  vars=dict(creator=creator),
                  order="atime DESC",
                  offset=offset,
                  limit=limit))
    for item in result:
        item.parent_name = query_note_name(item.parent_id)
    t.stop()
    xutils.trace("NoteDao.ListRecentViewed", "", t.cost_millis())
    return result
示例#11
0
文件: dao-old.py 项目: dudefu/xnote
def rdb_list_by_date(field, creator, date):
    db = xtables.get_file_table()
    date_pattern = date + "%"

    if field == "name":
        where = "creator = $creator AND is_deleted = 0 AND name LIKE $date"
        date_pattern = "%" + date + "%"
    elif field == "mtime":
        where = "creator = $creator AND is_deleted = 0 AND mtime LIKE $date"
    else:
        where = "creator = $creator AND is_deleted = 0 AND ctime LIKE $date"
    files = list(
        db.select(what="name, id, parent_id, ctime, mtime, type, creator",
                  where=where,
                  vars=dict(creator=creator, date=date_pattern),
                  order="name DESC"))
    fill_parent_name(files)
    return files
示例#12
0
文件: dao.py 项目: zenistzw/xnote
def list_recent_created(parent_id=None, offset=0, limit=10):
    t = Timer()
    t.start()
    where = "is_deleted = 0 AND (creator = $creator)"
    if parent_id != None:
        where += " AND parent_id = %s" % parent_id
    db = xtables.get_file_table()
    result = list(
        db.select(where=where,
                  vars=dict(creator=xauth.get_current_name()),
                  order="ctime DESC",
                  offset=offset,
                  limit=limit))
    for item in result:
        item.parent_name = query_note_name(item.parent_id)
    t.stop()
    xutils.trace("NoteDao.ListRecentCreated", "", t.cost_millis())
    return result
示例#13
0
文件: db.py 项目: chaplinthink/wechat
def get_fkcontent():
    return db.select('fk', order='id')
示例#14
0
def get_fkcontent():
    return db.select('fk1')
示例#15
0
def get_fkcontent():  # 得到所有的留言
	return db.select('fk', order='id')
示例#16
0
def get_fkcontent():
    return db.select('fk', order='id')
示例#17
0
def get_todos():
    return db.select('todo', order='id')
示例#18
0
def get_all(_table):
    return db.select(_table, order = 'id')
示例#19
0
def get_content():
    return db.select('morning_sign', order='timetoday DESC')
示例#20
0
def getremain():
	#return db.query("SELECT * FROM Ticket WHERE Date =  AND Direction = $direction", vars={'direction':1,'date':2015-06-10})
	return db.select('Ticket', order='Date')
示例#21
0
def get_content():
    return db.select('morning_enroll', order='id')