Example #1
0
 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
Example #3
0
 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
Example #4
0
    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)
Example #5
0
 def __exit__(self, type, value, traceback):
     setSession()
Example #6
0
 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()
Example #7
0
 def __enter__(self):
     setSession(self.session)
     return self.session
Example #8
0
def teardown_module(module):
    """ undo groking
    """
    setSession()
    testing.teardown()
Example #9
0
def setup_module(module):
    """ grok the publish module
    """
    testing.setup()
    setSession(SESSION)
    crom.configure(dolmen.message)
Example #10
0
 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()
Example #11
0
 def __enter__(self):
     setSession(self.session)
     return self.session
Example #12
0
def teardown_module(module):
    """ undo groking
    """
    setSession()
    cleanUp()
Example #13
0
def setup_module(module):
    """ grok the publish module
    """
    setSession(SESSION)
    grok.testing.grok("dolmen.message.components")