Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 983

Show
Ignore:
Timestamp:
02/28/06 09:43:56
Author:
rdelon
Message:

Fix for #293: better error message if sessionfilter.storage_path is not set (and "file" backend is set)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/filters/sessionfilter.py

    r979 r983  
    5353class SessionNotEnabledError(Exception): 
    5454    """ User forgot to set session_filter.on to True """ 
     55    pass 
     56 
     57class SessionStoragePathNotConfiguredError(Exception): 
     58    """ 
     59    User set storage_type to file but forgot to set the storage_path 
     60    """ 
    5561    pass 
    5662 
     
    288294     
    289295    def clean_up(self, sess): 
    290         storagePath = cherrypy.config.get('session_filter.storage_path') 
     296        storage_path = cherrypy.config.get('session_filter.storage_path') 
    291297        now = datetime.datetime.now() 
    292298        # Iterate over all files in the dir/ and exclude non session files 
    293299        #   and lock files 
    294         for fname in os.listdir(storagePath): 
     300        for fname in os.listdir(storage_path): 
    295301            if (fname.startswith(self.SESSION_PREFIX) 
    296302                and not fname.endswith(self.LOCK_SUFFIX)): 
    297303                # We have a session file: try to load it and check 
    298304                #   if it's expired. If it fails, nevermind. 
    299                 filePath = os.path.join(storagePath, fname) 
     305                filePath = os.path.join(storage_path, fname) 
    300306                try: 
    301307                    f = open(filePath, "rb") 
     
    312318     
    313319    def _getFilePath(self, id): 
    314         storagePath = cherrypy.config.get('session_filter.storage_path') 
     320        storage_path = cherrypy.config.get('session_filter.storage_path') 
     321        if storage_path is None: 
     322            raise SessionStoragePathNotConfiguredError() 
    315323        fileName = self.SESSION_PREFIX + id 
    316         filePath = os.path.join(storagePath, fileName) 
     324        filePath = os.path.join(storage_path, fileName) 
    317325        return filePath 
    318326     

Hosted by WebFaction

Log in as guest/cpguest to create tickets