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

Changeset 1407

Show
Ignore:
Timestamp:
10/22/06 16:54:12
Author:
fumanchu
Message:

Fixed hang on InternalRedirect? with sessions tool.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/lib/sessions.py

    r1370 r1407  
    212212 
    213213class FileSession(Session): 
    214     """ Implementation of the File backend for sessions """ 
     214    """ Implementation of the File backend for sessions 
     215     
     216    storage_path: the folder where session data will be saved. Each session 
     217        will be saved as pickle.dump(data, expiration_time) in its own file; 
     218        the filename will be self.SESSION_PREFIX + self.id. 
     219    """ 
    215220     
    216221    SESSION_PREFIX = 'session-' 
     
    240245     
    241246    def _delete(self): 
    242         os.unlink(self._get_file_path()) 
     247        try: 
     248            os.unlink(self._get_file_path()) 
     249        except OSError: 
     250            pass 
    243251     
    244252    def acquire_lock(self, path=None): 
     
    389397    request = cherrypy.request 
    390398     
     399    # Guard against running twice 
     400    if hasattr(cherrypy._serving, "session"): 
     401        return 
     402     
    391403    # Check if request came with a session ID 
    392404    id = None 
  • trunk/cherrypy/test/test_session.py

    r1287 r1407  
    5151            return "done" 
    5252        delete.exposed = True 
     53         
     54        def blah(self): 
     55            return self._cp_config['tools.sessions.storage_type'] 
     56        blah.exposed = True 
     57         
     58        def iredir(self): 
     59            raise cherrypy.InternalRedirect('/blah') 
     60        iredir.exposed = True 
    5361     
    5462    cherrypy.tree.mount(Root()) 
    5563    cherrypy.config.update({'environment': 'test_suite'}) 
     64 
    5665 
    5766from cherrypy.test import helper 
     
    134143        expected = 1 + (client_thread_count * request_count) 
    135144        self.assertEqual(hitcount, expected) 
     145     
     146    def test_3_Redirect(self): 
     147        # Start a new session 
     148        self.getPage('/testStr') 
     149        self.getPage('/iredir', self.cookies) 
     150        self.assertBody("file") 
     151     
     152    def test_4_File_deletion(self): 
     153        # Start a new session 
     154        self.getPage('/testStr') 
     155        # Delete the session file manually and retry. 
     156        id = self.cookies[0][1].split(";", 1)[0].split("=", 1)[1] 
     157        path = os.path.join(localDir, "session-" + id) 
     158        os.unlink(path) 
     159        self.getPage('/testStr', self.cookies) 
    136160 
    137161 

Hosted by WebFaction

Log in as guest/cpguest to create tickets