Example #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 ""
Example #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 ""
Example #3
0
def update_children_count(parent_id, db=None):
    if parent_id is None or parent_id == "":
        return
    if db is None:
        db = get_file_db()
    group_count = db.count(where="parent_id=$parent_id AND is_deleted=0",
                           vars=dict(parent_id=parent_id))
    db.update(size=group_count, where=dict(id=parent_id))
Example #4
0
 def POST(self):
     id = xutils.get_argument("id", type=int)
     content = xutils.get_argument("content")
     name = xutils.get_argument("name")
     db = xtables.get_file_table()
     # record = db.select_one(where={"id": id})
     if name != "":
         db.update(where={"id": id}, content=content, name=name)
     else:
         db.update(where={"id": id}, content=content)
     return dict(code="success")
Example #5
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)
Example #6
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
Example #7
0
def update(where, **kw):
    db = get_file_db()
    kw["mtime"] = dateutil.format_time()
    # 处理乐观锁
    version = where.get("version")
    if version:
        kw["version"] = version + 1
    return db.update(where=where, vars=None, **kw)
Example #8
0
def rdb_update_note(where, **kw):
    db = xtables.get_file_table()
    note_id = where.get('id')
    content = kw.get('content')
    data = kw.get('data')

    kw["mtime"] = dateutil.format_time()
    kw["atime"] = dateutil.format_time()
    # 处理乐观锁
    version = where.get("version")
    if version != None:
        kw["version"] = version + 1
    # 这两个字段废弃,移动到单独的表中
    if 'content' in kw:
        del kw['content']
        kw['content'] = ''
    if 'data' in kw:
        del kw['data']
        kw['data'] = ''
    rows = db.update(where=where, vars=None, **kw)
    if rows > 0:
        # 更新成功后再更新内容,不考虑极端的冲突情况
        update_note_content(note_id, content, data)
    return rows
Example #9
0
def wuruid(username, product_id):
    #Old Product
    #Return checkcode for wuchu guy to confirm
    checkcode = gen_checkcode()
    db.update('shareit', where = 'product_id = $pro_id', vars = dict(pro_id = product_id), checkcode_user = checkcode + '_' + username )
    return checkcode
Example #10
0
def evaluate(status, orderid):
    db = connectDB()

    db.update('orders', where='orderid=$id', vars={'id': int(orderid)}, status=int(status))
Example #11
0
def recieveOrder(userid, orderid):
    db = connectDB()

    db.update('orders', where='orderid=$id', vars={'id': int(orderid)}, serveid = userid, status=0)
    db.delete('dmdpool', where='orderid=$id', vars={'id': int(orderid)})
Example #12
0
def update(user,total,last_record,all_record,timetoday):
    total+=1
        
    db.update('morning_sign',where='user=$user',vars={'user':user},istoday=1,timetoday=timetoday,total=total,last_record=last_record,all_record=all_record)
def get_update(_table):
    db.update(_table, where="id = 1", openID = '456', keyword = "123,456,789")
Example #14
0
def addfk(time, numOfRoom,pm25,pm10,tem,dam,co2):
    return db.update('fk1',where='id=$id',vars={'id':(int)(numOfRoom)},time=time, numOfRoom=numOfRoom, pm25=pm25,pm10=pm10,tem=tem,dam=dam,co2=co2)