Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #6082: file-based sessions now verify that SESSION_FILE_PATH is…

… a valid storage location, and raise ImproperlyConfigured if not. Thanks, jags78.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6889 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 602b7bca7aa0b94bb38ba16735635959e04d91ab 1 parent 76dd53a
@jacobian jacobian authored
Showing with 11 additions and 2 deletions.
  1. +11 −2 django/contrib/sessions/backends/file.py
View
13 django/contrib/sessions/backends/file.py
@@ -1,14 +1,23 @@
import os
+import tempfile
from django.conf import settings
from django.contrib.sessions.backends.base import SessionBase
-from django.core.exceptions import SuspiciousOperation
+from django.core.exceptions import SuspiciousOperation, ImproperlyConfigured
class SessionStore(SessionBase):
"""
Implements a file based session store.
"""
def __init__(self, session_key=None):
- self.storage_path = settings.SESSION_FILE_PATH
+ self.storage_path = getattr(settings, "SESSION_FILE_PATH", tempfile.gettempdir())
+
+ # Make sure the storage path is valid.
+ if not os.path.isdir(self.storage_path):
+ raise ImproperlyConfigured("The session storage path %r doesn't exist. "\
+ "Please set your SESSION_FILE_PATH setting "\
+ "to an existing directory in which Django "\
+ "can store session data." % self.storage_path)
+
self.file_prefix = settings.SESSION_COOKIE_NAME
super(SessionStore, self).__init__(session_key)

0 comments on commit 602b7bc

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