X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=wrw%2Fsession.py;h=476113ad59f66a0d0ac8f5cad2047e85f1f3902e;hb=b6f62b898efdc272130d3dbdd6742c5b785e7c7d;hp=1e615e3d22b52cb4ded26acb05fd3cd4b8252b86;hpb=9bc70dab473c7057a20d182ce8566ad0a70a7c5d;p=wrw.git diff --git a/wrw/session.py b/wrw/session.py index 1e615e3..476113a 100644 --- a/wrw/session.py +++ b/wrw/session.py @@ -1,23 +1,18 @@ import threading, time, pickle, random, os +<<<<<<< HEAD import cookie, env +======= +from . import cookie, env, proto +>>>>>>> master __all__ = ["db", "get"] -def hexencode(str): - ret = "" - for byte in str: - ret += "%02X" % (ord(byte),) - return ret - def gennonce(length): - nonce = "" - for i in xrange(length): - nonce += chr(random.randint(0, 255)) - return nonce + return os.urandom(length) class session(object): def __init__(self, lock, expire=86400 * 7): - self.id = hexencode(gennonce(16)) + self.id = proto.enhex(gennonce(16)) self.dict = {} self.lock = lock self.ctime = self.atime = self.mtime = int(time.time())