def test_bootstrapSusbcriber(self):
        self.createRFAndSM()

        event = DatabaseOpened(self.db)
        # this will open and close the database by itself
        sessionBootstrapSubscriber(event)

        db, connection, root, root_folder = getInformationFromEvent(event)

        got_utility = zope.component.getUtility(IClientIdManager,
                                                context=root_folder)
        self.assertTrue(IClientIdManager.providedBy(got_utility))

        got_utility = zope.component.getUtility(ISessionDataContainer,
                                                context=root_folder)
        self.assertTrue(ISessionDataContainer.providedBy(got_utility))

        # we need to close again in the end
        connection.close()
Example #2
0
    def test_sdc_basics(self):
        # Make sure we have the correct class and it provides the required
        # interface.
        self.failUnless(isinstance(self.sdc, PGSessionDataContainer))
        self.failUnless(ISessionDataContainer.providedBy(self.sdc))

        client_id = 'Client Id'

        # __getitem__ does not raise a keyerror for an unknown client id.
        # This is not correct, but needed to work around a design flaw in
        # the session machinery.
        self.assertNotEqual(None, self.sdc['Unknown client id'])

        # __setitem__ calls are ignored.
        self.sdc[client_id] = 'ignored'

        # Once __setitem__ is called, we can access the SessionData
        session_data = self.sdc[client_id]
        self.failUnless(isinstance(session_data, PGSessionData))
        self.failUnless(ISessionData.providedBy(session_data))
Example #3
0
 def isAvailable(self):
     session = self.session
     return session is not None and ISessionDataContainer.providedBy(session)