Fixed #5548 -- Reintroduced Jython workaround for os.getpid(), which was lost in [6270]. Thanks, leosoto

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6386 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2007-09-20 02:19:48 +00:00
parent 24588afe6d
commit 3db846cdb5
1 changed files with 7 additions and 2 deletions

View File

@ -82,9 +82,14 @@ class SessionBase(object):
"Returns session key that isn't being used." "Returns session key that isn't being used."
# The random module is seeded when this Apache child is created. # The random module is seeded when this Apache child is created.
# Use settings.SECRET_KEY as added salt. # Use settings.SECRET_KEY as added salt.
try:
pid = os.getpid()
except AttributeError:
# No getpid() in Jython, for example
pid = 1
while 1: while 1:
session_key = md5.new("%s%s%s%s" % (random.randint(0, sys.maxint - 1), session_key = md5.new("%s%s%s%s" % (random.randint(0, sys.maxint - 1),
os.getpid(), time.time(), settings.SECRET_KEY)).hexdigest() pid, time.time(), settings.SECRET_KEY)).hexdigest()
if not self.exists(session_key): if not self.exists(session_key):
break break
return session_key return session_key