def testFileStoreRestoreFiles(self):
     app = self._app
     store = SessionFileStore(app)
     self.assertEqual(len(store), 7)
     self.assertTrue('foo-0' in store and 'foo-6' in store)
     store = SessionFileStore(app, restoreFiles=False)
     self.assertEqual(len(store), 0)
     self.assertFalse('foo-0' in store or 'foo-6' in store)
 def __init__(self, app, restoreFiles=1):
     SessionStore.__init__(self, app)
     self._store = {}
     if restoreFiles == 1:
         filestore = SessionFileStore(app)
         keys = filestore.keys()
         for i in keys:
             self[i] = filestore[i]
         filestore.clear()
Exemple #3
0
    def __init__(self, app, restoreFiles=True):
        """Initialize the session memory store.

        If restoreFiles is true, and sessions have been saved to file,
        the store will be initialized from these files.
        """
        SessionStore.__init__(self, app)
        self._store = {}
        if restoreFiles:
            filestore = SessionFileStore(app)
            for key in filestore:
                try:
                    self[key] = filestore[key]
                except Exception:
                    app.handleException()
            filestore.clear()
Exemple #4
0
 def storeAllSessions(self):
     """Permanently save all sessions in the store."""
     if self._restoreFiles:
         filestore = SessionFileStore(self._app)
         for key, session in self.items():
             filestore[key] = session
 def storeAllSessions(self):
     filestore = SessionFileStore(self._app)
     for i in self.keys():
         filestore[i] = self[i]