'Return a new session ID tuple (key, num)
The key is a unique and not-trivial-to-guess alphanumeric value
associated with the session.
The num is a unique numerical value associated with the session.'

def generate_session(self):

    r = self._next_ses
    self._next_ses += 1
    key = ((str(random.random()) + str(time.time())) + str(r))
    key += (str(id(key)) + self._session_salt)
    key = b32encode(hashlib.md5(key).digest()).upper().replace('=', '')
    def alphahex(r):
        "    base    16    on    digits    'a'    through    'p'    "
        r = hex(r)[2:].lower()
        return ''.join((chr(((10 if (ord(x) >= 97) else 49) + ord(x))) for x in r))
    key = (alphahex(r) + key)
    return (key, r)
