Permalink
Browse files

Ahem. Copy Twisted's session ID generation into SessionManager

  • Loading branch information...
brendonh committed Apr 29, 2012
1 parent 7b6ad3a commit 22fa96a418127ab69541630628b9dfd9f95d3ec2
Showing with 8 additions and 0 deletions.
  1. +8 −0 warp/common/avatar.py
View
@@ -47,6 +47,8 @@ class SessionManager(object):
Default DB-backed session handling
"""
+ counter = 0
+
def createSession(self):
uid = self._mkuid()
session = DBSession()
@@ -58,6 +60,12 @@ def createSession(self):
def getSession(self, uid):
return runtime.avatar_store.get(DBSession, uid)
+ def _mkuid(self):
+ from twisted.python.hashlib import md5
+ import random
+ self.counter = self.counter + 1
+ return md5("%s_%s" % (str(random.random()) , str(self.counter))).hexdigest()
+
class DBSession(Storm):
__storm_table__ = "warp_session"

0 comments on commit 22fa96a

Please sign in to comment.