示例#1
0
文件: Registion.py 项目: drxbate/M1
def calcUserCode(CD):
    monthcode="%4d%2d"%time.localtime()
    lsn = RedisCli.get("registion:lsn")
    if lsn is None:
        lsn=1
    RedisCli.set("registion:lsn",lsn)
    return "%s%s-%06d"%(CD,monthcode,lsn)
示例#2
0
文件: Session.py 项目: drxbate/M1
def createSession(userid):
    ssid = RedisCli.hget("sessions:users",userid)
    if ssid==None or ssid=="":
        clearSession(ssid)
    ssid=uuid.uuid1()
    RedisCli.hset("sessions:users",userid, ssid)
    return ssid
示例#3
0
文件: Security.py 项目: drxbate/q2k
def set_right(objectid,rights):
    """
    set list
    [{"name":"value(0:allow|1:deny|Otherwise:inherits)"},....]
    """
    name = "Security:rights:%s"%objectid
    for i in rights:
        RedisCli.hset(name, i["name"], i["value"])
示例#4
0
文件: Security.py 项目: drxbate/q2k
def get_rights(objectid):
    """
    return:rights
    [{"name":"value(0:allow|1:deny|Otherwise:inherits)"},....]
    e.g.
    [{"set_password_others":"0"}]
    """
    return RedisCli.hgetall("Security:rights:%s"%objectid)
示例#5
0
文件: Session.py 项目: drxbate/M1
def loadSession(ssid):
    dict = RedisCli.hgetall("sessions:data:%s"%ssid)
    ss={}
    for k,v in dict.items():
        try:
            ss[k] = json.loads(v)
        except:
            ss[k] = v
    return ss
示例#6
0
文件: Registion.py 项目: drxbate/M1
def popRegistQueue():
    e = RedisCli.lpop("registion:queue")
    return None if e==None else json.loads(e)
示例#7
0
文件: Registion.py 项目: drxbate/M1
def pushRegistQueue(username,password,info=[]):
    e = {"username":username,"password":password,"info":info}
    RedisCli.rpush("registion:queue",json.dumps(e))
示例#8
0
文件: Security.py 项目: drxbate/q2k
def clear_right(objectid):
    name = "Security:rights:%s"%objectid
    RedisCli.hdel(name)
示例#9
0
文件: Security.py 项目: drxbate/q2k
def check_right(objectid,right):
    name = "Security:rights:%s"%objectid
    return RedisCli.hget(name, right)
示例#10
0
文件: Security.py 项目: drxbate/q2k
def exists(code):
    return RedisCli.exists("Security:bindCode:%s"%code)
示例#11
0
文件: Security.py 项目: drxbate/q2k
def loadCode(code,keepAlive=False):
    if keepAlive:
        js=RedisCli.get("Security:bindCode:%s"%code)
    else:
        js = RedisCli.getset("Security:bindCode:%s"%code, "")
    return None if js=="" else json.loads(js)
示例#12
0
文件: Security.py 项目: drxbate/q2k
def bindCode(code,info={},expire=30):
    RedisCli.set("Security:bindCode:%s"%code, json.dumps(info),ex=expire*60)
示例#13
0
文件: Session.py 项目: drxbate/M1
def clearSession(ssid):
    RedisCli.delete("sessions:data:%s"%ssid)#2小时超时
示例#14
0
文件: Session.py 项目: drxbate/M1
def updateSession(ssid,dict={}):
    RedisCli.expire("sessions:data:%s"%ssid, 120*60)#2小时超时
    RedisCli.hmset("sessions:data:%s"%ssid, dict)