MCPcopy
hub / github.com/cherrypy/cherrypy / load

Method load

cherrypy/lib/sessions.py:283–312  ·  view source on GitHub ↗

Copy stored session data into this session instance.

(self)

Source from the content-addressed store, hash-verified

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."""

Callers 13

__getitem__Method · 0.95
__setitem__Method · 0.95
__delitem__Method · 0.95
popMethod · 0.95
__contains__Method · 0.95
getMethod · 0.95
updateMethod · 0.95
setdefaultMethod · 0.95
clearMethod · 0.95
keysMethod · 0.95
itemsMethod · 0.95
valuesMethod · 0.95

Calls 5

nowMethod · 0.95
startMethod · 0.95
logMethod · 0.80
_loadMethod · 0.45
subscribeMethod · 0.45

Tested by

no test coverage detected