Ticket #1180: sessions.uuid.patch
File sessions.uuid.patch, 1.1 KB (added by , 17 years ago) |
---|
-
base.py
12 12 except ImportError: 13 13 import pickle 14 14 15 try: 16 import uuid 17 except: 18 import django.utils.uuid as uuid 19 15 20 class SessionBase(object): 16 21 """ 17 22 Base class for all Session classes. … … 88 93 89 94 def _get_new_session_key(self): 90 95 "Returns session key that isn't being used." 91 # The random module is seeded when this Apache child is created. 92 # Use settings.SECRET_KEY as added salt. 93 try: 94 pid = os.getpid() 95 except AttributeError: 96 # No getpid() in Jython, for example 97 pid = 1 96 # The generated key is a UUID as defined in http://www.faqs.org/rfcs/rfc4122.html 98 97 while 1: 99 session_key = md5.new("%s%s%s%s" % (random.randint(0, sys.maxint - 1), 100 pid, time.time(), settings.SECRET_KEY)).hexdigest() 98 session_key = uuid4().hex 101 99 if not self.exists(session_key): 102 100 break 103 101 return session_key