Skip to content

Commit

Permalink
Fixed #5548 -- Reintroduced Jython workaround for os.getpid(), which …
Browse files Browse the repository at this point in the history
…was lost in [6270]. Thanks, leosoto

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6386 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
adrianholovaty committed Sep 20, 2007
1 parent 24588af commit 3db846c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions django/contrib/sessions/backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,14 @@ def _get_new_session_key(self):
"Returns session key that isn't being used."
# The random module is seeded when this Apache child is created.
# Use settings.SECRET_KEY as added salt.
try:
pid = os.getpid()
except AttributeError:
# No getpid() in Jython, for example
pid = 1
while 1:
session_key = md5.new("%s%s%s%s" % (random.randint(0, sys.maxint - 1),
os.getpid(), time.time(), settings.SECRET_KEY)).hexdigest()
session_key = md5.new("%s%s%s%s" % (random.randint(0, sys.maxint - 1),
pid, time.time(), settings.SECRET_KEY)).hexdigest()
if not self.exists(session_key):
break
return session_key
Expand Down

0 comments on commit 3db846c

Please sign in to comment.