Copy stored session data into this session instance.
(self)
| 281 | cherrypy.log('Lock released after save.', 'TOOLS.SESSIONS') |
| 282 | |
| 283 | def load(self): |
| 284 | """Copy stored session data into this session instance.""" |
| 285 | data = self._load() |
| 286 | # data is either None or a tuple (session_data, expiration_time) |
| 287 | if data is None or data[1] < self.now(): |
| 288 | if self.debug: |
| 289 | cherrypy.log('Expired session %r, flushing data.' % self.id, |
| 290 | 'TOOLS.SESSIONS') |
| 291 | self._data = {} |
| 292 | else: |
| 293 | if self.debug: |
| 294 | cherrypy.log('Data loaded for session %r.' % self.id, |
| 295 | 'TOOLS.SESSIONS') |
| 296 | self._data = data[0] |
| 297 | self.loaded = True |
| 298 | |
| 299 | # Stick the clean_thread in the class, not the instance. |
| 300 | # The instances are created and destroyed per-request. |
| 301 | cls = self.__class__ |
| 302 | if self.clean_freq and not cls.clean_thread: |
| 303 | # clean_up is an instancemethod and not a classmethod, |
| 304 | # so that tool config can be accessed inside the method. |
| 305 | t = cherrypy.process.plugins.Monitor( |
| 306 | cherrypy.engine, self.clean_up, self.clean_freq * 60, |
| 307 | name='Session cleanup') |
| 308 | t.subscribe() |
| 309 | cls.clean_thread = t |
| 310 | t.start() |
| 311 | if self.debug: |
| 312 | cherrypy.log('Started cleanup thread.', 'TOOLS.SESSIONS') |
| 313 | |
| 314 | def delete(self): |
| 315 | """Delete stored session data.""" |
no test coverage detected