def render(self): session = ISession(self.request, None) if 'testsessionkey' in self.request: session['testsessionkey'] = dict(key1='Hey', key2='Boy') session.save() return 'Test key stored...' if 'testsessionkey2' in self.request: session['testsessionkey2'] = dict(key1='Hey', key2='Boy') session.save() return 'Test key2 stored...' if 'remove' in self.request: session.delete() session.invalidate() return 'Session removed and destroyed...' if session is None: return 'No session initiatied' if 'testsessionkey' in session: return 'Found session: ' + str(session) else: return 'Did not find testsessionkey in session...'
def test_invalidated(self): provideAdapter(testingSession) request = TestRequest() session = ISession(request) self.assertEquals(False, session._invalidated) session.invalidate() self.assertEquals(True, session._invalidated)
def __call__(self): session = ISession(self.request) if 'reset' in self.request: session['testCounter'] = 0 session.save() if 'increment' in self.request: session['testCounter'] += 1 session.save() if 'invalidate' in self.request: session.invalidate() if 'delete' in self.request: session.delete() return str(session.get('testCounter', -1))