Exemple #1
0
    def wrapper(*args, **kwargs):
        server = weblab_api.ctx.server_instance
        if weblab_api.ctx.reservation_id is None:
            raise coreExc.SessionNotFoundError(
                "Core Reservations session not found")

        reservation_id = SessionId(weblab_api.ctx.reservation_id.split(';')[0])
        try:
            session = server._reservations_session_manager.get_session_locking(
                reservation_id)
        except SessionNotFoundError:
            raise coreExc.SessionNotFoundError(
                "Core Reservations session not found")

        try:
            weblab_api.ctx.reservation_session = session
            weblab_api.ctx.reservation_processor = server._load_reservation(
                session)
            try:
                return func(*args, **kwargs)
            finally:
                weblab_api.ctx.reservation_processor.update_latest_timestamp()
        finally:
            server._reservations_session_manager.modify_session_unlocking(
                reservation_id, session)
Exemple #2
0
def logout():
    server_instance = weblab_api.ctx.server_instance
    if not weblab_api.ctx.session_id:
        raise coreExc.SessionNotFoundError( "User Processing Server session not found")
        
    session_id = SessionId(weblab_api.ctx.session_id)

    if server_instance._session_manager.has_session(session_id):
        session        = server_instance._session_manager.get_session(session_id)

        user_processor = server_instance._load_user(session)

        reservation_id = session.get('reservation_id')
        if reservation_id is not None and not user_processor.is_access_forward_enabled():
            #
            # If "is_access_forward_enabled", the user (or more commonly, entity) can log out without
            # finishing his current reservation
            #
            # Furthermore, whenever booking is supported, this whole idea should be taken out. Even
            # with queues it might not make sense, depending on the particular type of experiment.
            #
            reservation_session = server_instance._reservations_session_manager.get_session(SessionId(reservation_id))
            reservation_processor = server_instance._load_reservation(reservation_session)
            reservation_processor.finish()
            server_instance._alive_users_collection.remove_user(reservation_id)

        user_processor.logout()
        user_processor.update_latest_timestamp()

        server_instance._session_manager.delete_session(session_id)
        return {}
    else:
        raise coreExc.SessionNotFoundError( "User Processing Server session not found")
Exemple #3
0
        def test_logout(self):
            self.configurationManager._set_value(self.rfs.FACADE_ZSI_PORT, 14124)
            self.rfs.start()
            try:
                wds = UserProcessingWebLabDeustoSOAP("http://localhost:14124/weblab/soap/")

                expected_sess_id = SessionId.SessionId("whatever")
                MESSAGE  = 'my message'

                self.mock_server.return_values['logout'] = expected_sess_id

                wds.logout(expected_sess_id)

                self.assertEquals(
                        expected_sess_id.id,
                        self.mock_server.arguments['logout'][0]
                    )

                self.mock_server.exceptions['logout'] = coreExc.SessionNotFoundError(MESSAGE)

                try:
                    wds.logout(expected_sess_id)
                    self.fail('exception expected')
                except ZSI.FaultException as e:
                    self.assertEquals(
                        UserProcessingRFCodes.CLIENT_SESSION_NOT_FOUND_EXCEPTION_CODE,
                        e.fault.code[1]
                    )
                    self.assertEquals(
                        MESSAGE,
                        e.fault.string
                    )
            finally:
                self.rfs.stop()
Exemple #4
0
def get_reservation_experiment_info():
    # First poll, then run it
    try:
        reservation_processor = weblab_api.ctx.reservation_processor
        weblab_api.ctx.server_instance._check_reservation_not_expired_and_poll( reservation_processor )
    except coreExc.NoCurrentReservationError:
        raise coreExc.SessionNotFoundError("reservation expired")

    experiment_id = weblab_api.ctx.reservation_session['experiment_id']
    return weblab_api.db.get_experiment(experiment_id.exp_name, experiment_id.cat_name)