Changeset 1924
- Timestamp:
- 03/16/08 10:33:19
- Files:
-
- trunk/cherrypy/lib/sessions.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/lib/sessions.py
r1922 r1924 74 74 else: 75 75 self.id = id 76 if self._load() is None:76 if not self._exists(): 77 77 # Expired or malicious session. Make a new one. 78 78 # See http://www.cherrypy.org/ticket/709. … … 93 93 self.id = self.generate_id() 94 94 # Assert that the generated id is not already stored. 95 if self._ load() is not None:95 if self._exists(): 96 96 self.id = None 97 97 … … 245 245 pass 246 246 247 def _exists(self): 248 return self.id in self.cache 249 247 250 def _load(self): 248 251 return self.cache.get(self.id) … … 270 273 271 274 class FileSession(Session): 272 """ Implementation of the File backend for sessions275 """Implementation of the File backend for sessions 273 276 274 277 storage_path: the folder where session data will be saved. Each session … … 309 312 raise cherrypy.HTTPError(400, "Invalid session id in cookie.") 310 313 return f 314 315 def _exists(self): 316 path = self._get_file_path() 317 return os.path.exists(path) 311 318 312 319 def _load(self, path=None): … … 420 427 self.db.commit() 421 428 429 def _exists(self): 430 # Select session data from table 431 self.cursor.execute('select data, expiration_time from session ' 432 'where id=%s', (self.id,)) 433 rows = self.cursor.fetchall() 434 return bool(rows) 435 422 436 def _load(self): 423 437 # Select session data from table … … 484 498 cls.cache = memcache.Client(cls.servers) 485 499 setup = classmethod(setup) 500 501 def _exists(self): 502 self.mc_lock.acquire() 503 try: 504 return bool(self.cache.get(self.id)) 505 finally: 506 self.mc_lock.release() 486 507 487 508 def _load(self):

