Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit 3db846cdb5ac8606ed66a8dce55f0644f6c1cce3 1 parent 24588af
Adrian Holovaty authored September 20, 2007

Showing 1 changed file with 7 additions and 2 deletions. Show diff stats Hide diff stats

  1. 9  django/contrib/sessions/backends/base.py
9  django/contrib/sessions/backends/base.py
@@ -82,9 +82,14 @@ def _get_new_session_key(self):
82 82
         "Returns session key that isn't being used."
83 83
         # The random module is seeded when this Apache child is created.
84 84
         # Use settings.SECRET_KEY as added salt.
  85
+        try:
  86
+            pid = os.getpid()
  87
+        except AttributeError:
  88
+            # No getpid() in Jython, for example
  89
+            pid = 1
85 90
         while 1:
86  
-            session_key = md5.new("%s%s%s%s" % (random.randint(0, sys.maxint - 1), 
87  
-                                  os.getpid(), time.time(), settings.SECRET_KEY)).hexdigest()
  91
+            session_key = md5.new("%s%s%s%s" % (random.randint(0, sys.maxint - 1),
  92
+                                  pid, time.time(), settings.SECRET_KEY)).hexdigest()
88 93
             if not self.exists(session_key):
89 94
                 break
90 95
         return session_key

0 notes on commit 3db846c

Please sign in to comment.
Something went wrong with that request. Please try again.