summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-09-15 09:51:41 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-09-15 09:51:41 +0000
commitcd8959c82ace7105d47a082cc7c4a07f61f94f60 (patch)
treed400ef8f527f666175a20d8a1ee5958cec0a47ec
parent1baae32e16e8eee5bc239bfea8674651b765a41f (diff)
Fixed #5486 -- Worked around the lack of os.getpid() in Jython, whilst still using it for CPython. Patch from Leo Soto.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6270 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/sessions/models.py7
-rw-r--r--django/core/mail.py6
2 files changed, 11 insertions, 2 deletions
diff --git a/django/contrib/sessions/models.py b/django/contrib/sessions/models.py
index 29adc6e30c..fda10c9743 100644
--- a/django/contrib/sessions/models.py
+++ b/django/contrib/sessions/models.py
@@ -15,8 +15,13 @@ class SessionManager(models.Manager):
"Returns session key that isn't being used."
# The random module is seeded when this Apache child is created.
# Use 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()
try:
self.get(session_key=session_key)
except self.model.DoesNotExist:
diff --git a/django/core/mail.py b/django/core/mail.py
index ff653400f9..b90752e649 100644
--- a/django/core/mail.py
+++ b/django/core/mail.py
@@ -50,7 +50,11 @@ def make_msgid(idstring=None):
"""
timeval = time.time()
utcdate = time.strftime('%Y%m%d%H%M%S', time.gmtime(timeval))
- pid = os.getpid()
+ try:
+ pid = os.getpid()
+ except AttributeError:
+ # Not getpid() in Jython, for example.
+ pid = 1
randint = random.randrange(100000)
if idstring is None:
idstring = ''