def __enter__(self): if self.transaction_manager is not None: dm = WsgistateDataManager(self.manager) self.transaction_manager.join(dm) setSession(dm) return dm else: setSession(self.manager.session) return self.manager.session
def test_session(): session_object = object() browser.setSession(session_object) assert browser.session.sessioninfo.__class__ == ( browser.session.SessionInfo) assert browser.session.sessioninfo.session is session_object assert browser.session.sessioninfo.session is browser.getSession() browser.setSession() assert browser.session.sessioninfo.session is None assert browser.session.sessioninfo.session is None
def caller(environ, start_response): if plugin is None: session = environ.get(key) setSession(session) response = wrapped(environ, start_response) setSession(None) return response else: manager = session_managers.get(plugin) if manager is None: raise NotImplementedError('Unknown session plugin "%s"' % plugin) else: with manager(environ, key): response = wrapped(environ, start_response) return response
def publisher(environ, start_response): @tlib.signed_cookie(pubkey) def publish(request, root): view = uvclight.query_view(request, site, name=u'index') if view is not None: return view return uvclight.query_view(request, site, name=u'notfound'), None session = environ[session_key].session setSession(session) request = Request(environ) view, error = publish(request, site) if error is not None: view = uvclight.query_view(request, site, name=u'unauthorized') view.set_message(error.title) response = view() return response(environ, start_response)
def __exit__(self, type, value, traceback): setSession()
def __exit__(self, type, value, traceback): # Traceback or not, we reset the session thread-local. # Exiting the block, we don't want the session set. self.session = None # Remove the reference. setSession()
def __enter__(self): setSession(self.session) return self.session
def teardown_module(module): """ undo groking """ setSession() testing.teardown()
def setup_module(module): """ grok the publish module """ testing.setup() setSession(SESSION) crom.configure(dolmen.message)
def teardown_module(module): """ undo groking """ setSession() cleanUp()
def setup_module(module): """ grok the publish module """ setSession(SESSION) grok.testing.grok("dolmen.message.components")