def __init__(self, username=None,userID=None): self.username = username self.userID = userID if self.userID == None: self.userID = login.getuserID(username) else: self.userID = userID self.sessionID = 0 self.items = {}#itemID:item_name
def populate(self): self.userID = login.getuserID(self.username) #Cast to string to get first digits, cast to int for use as sessionID self.sessionID = int(str(random.getrandbits(128))[:17]) session_key = str(self.sessionID) user_key = str(self.userID) session.store(session_key, self.userID) session.store(user_key, self.sessionID) session.expire(session_key, TTL) session.expire(user_key, TTL)