Django

Code

Changeset 6889

Show
Ignore:
Timestamp:
12/04/07 14:24:22 (1 year ago)
Author:
jacob
Message:

Fixed #6082: file-based sessions now verify that SESSION_FILE_PATH is a valid storage location, and raise ImproperlyConfigured? if not. Thanks, jags78.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/contrib/sessions/backends/file.py

    r6348 r6889  
    11import os 
     2import tempfile 
    23from django.conf import settings 
    34from django.contrib.sessions.backends.base import SessionBase 
    4 from django.core.exceptions import SuspiciousOperation 
     5from django.core.exceptions import SuspiciousOperation, ImproperlyConfigured 
    56 
    67class SessionStore(SessionBase): 
     
    910    """ 
    1011    def __init__(self, session_key=None): 
    11         self.storage_path = settings.SESSION_FILE_PATH 
     12        self.storage_path = getattr(settings, "SESSION_FILE_PATH", tempfile.gettempdir()) 
     13         
     14        # Make sure the storage path is valid. 
     15        if not os.path.isdir(self.storage_path): 
     16            raise ImproperlyConfigured("The session storage path %r doesn't exist. "\ 
     17                                       "Please set your SESSION_FILE_PATH setting "\ 
     18                                       "to an existing directory in which Django "\ 
     19                                       "can store session data." % self.storage_path) 
     20         
    1221        self.file_prefix = settings.SESSION_COOKIE_NAME     
    1322        super(SessionStore, self).__init__(session_key)