Ticket #6082: 6082.diff
File 6082.diff, 1.6 KB (added by , 17 years ago) |
---|
-
contrib/sessions/backends/file.py
1 1 import os 2 2 from django.conf import settings 3 3 from django.contrib.sessions.backends.base import SessionBase 4 from django.core.exceptions import SuspiciousOperation 4 from django.core.exceptions import SuspiciousOperation, ImproperlyConfigured 5 5 6 6 class SessionStore(SessionBase): 7 7 """ … … 9 9 """ 10 10 def __init__(self, session_key=None): 11 11 self.storage_path = settings.SESSION_FILE_PATH 12 13 if not os.path.isdir(self.storage_path): 14 try: 15 if os.path.isdir(os.environ['TMPDIR']): 16 self.storage_path = os.environ['TMPDIR'] 17 except: 18 #fail silently 19 pass 20 try: 21 if os.path.isdir(os.environ['TEMP']): 22 self.storage_path = os.environ['TEMP'] 23 except: 24 #fail silently 25 pass 26 27 # If we still don't have a storage path we should error out here 28 # more than likely this will not happen 29 if not os.path.isdir(self.storage_path): 30 raise \ 31 ImproperlyConfigured("Storage path: %s is not a valid directory" % self.storage_path) 32 12 33 self.file_prefix = settings.SESSION_COOKIE_NAME 13 34 super(SessionStore, self).__init__(session_key) 14 35