Changeset 1407
- Timestamp:
- 10/22/06 16:54:12
- Files:
-
- trunk/cherrypy/lib/sessions.py (modified) (3 diffs)
- trunk/cherrypy/test/test_session.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/lib/sessions.py
r1370 r1407 212 212 213 213 class 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 """ 215 220 216 221 SESSION_PREFIX = 'session-' … … 240 245 241 246 def _delete(self): 242 os.unlink(self._get_file_path()) 247 try: 248 os.unlink(self._get_file_path()) 249 except OSError: 250 pass 243 251 244 252 def acquire_lock(self, path=None): … … 389 397 request = cherrypy.request 390 398 399 # Guard against running twice 400 if hasattr(cherrypy._serving, "session"): 401 return 402 391 403 # Check if request came with a session ID 392 404 id = None trunk/cherrypy/test/test_session.py
r1287 r1407 51 51 return "done" 52 52 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 53 61 54 62 cherrypy.tree.mount(Root()) 55 63 cherrypy.config.update({'environment': 'test_suite'}) 64 56 65 57 66 from cherrypy.test import helper … … 134 143 expected = 1 + (client_thread_count * request_count) 135 144 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) 136 160 137 161

