def reserve_experiment(self, experiment_id, serialized_client_initial_data, serialized_consumer_data, client_address, core_server_universal_id ):

        # Put user information in the session
        self.get_user_information()

        self._session['experiment_id'] = experiment_id

        reservation_info = self._session['reservation_information'] = {}
        reservation_info['user_agent']     = weblab_api.user_agent
        reservation_info['referer']        = weblab_api.referer
        reservation_info['mobile']         = weblab_api.is_mobile
        reservation_info['locale']         = weblab_api.locale
        reservation_info['facebook']       = weblab_api.is_facebook
        reservation_info['route']          = self._server_route or 'no-route-found'
        reservation_info['username']       = self.username
        reservation_info['from_ip']        = client_address
        reservation_info['from_direct_ip'] = client_address
#        reservation_info['full_name']      = self._session['user_information'].full_name
        reservation_info['role']           = self._session['db_session_id'].role

        try:
            client_initial_data = json.loads(serialized_client_initial_data)
        except ValueError:
            # TODO: to be tested
            raise core_exc.WebLabCoreError( "Invalid client_initial_data provided: a json-serialized object expected" )

        if self.is_access_forward_enabled():
            try:
                consumer_data = json.loads(serialized_consumer_data)
                for forwarded_key in FORWARDED_KEYS:
                    if forwarded_key in consumer_data:
                        if consumer_data[forwarded_key] is not None:
                            reservation_info[forwarded_key] = consumer_data[forwarded_key]

                server_uuids = consumer_data.get(SERVER_UUIDS, [])
                for server_uuid, server_uuid_human in server_uuids:
                    if server_uuid == core_server_universal_id:
                        return 'replicated'
                reservation_info[SERVER_UUIDS] = server_uuids
            except __HOLE__:
                raise core_exc.WebLabCoreError( "Invalid serialized_consumer_data provided: a json-serialized object expected" )
        else:
            consumer_data = {}


        experiments = self._db_manager.list_experiments(self.username, experiment_id.exp_name, experiment_id.cat_name)

        if len(experiments) == 0:
            raise core_exc.UnknownExperimentIdError( "User can't access that experiment (or that experiment type does not exist)" )

        experiment_allowed = experiments[0]
        try:
            # Retrieve the most restrictive values between what was requested and what was permitted:
            #
            # The smallest time allowed
            time_allowed                 = min(experiment_allowed.time_allowed,                consumer_data.get('time_allowed', experiment_allowed.time_allowed))
            #
            # The lowest priority (lower number is higher)
            # TODO: whenever possible, there should be an argument in the permission as
            # a parameter to the access_forward, such as:
            # "how much you want to decrement the requested priority to this user"
            priority                     = max(experiment_allowed.priority,                    consumer_data.get('priority', experiment_allowed.priority))

            #
            # Don't take into account initialization unless both agree
            initialization_in_accounting = experiment_allowed.initialization_in_accounting and consumer_data.get('initialization_in_accounting', experiment_allowed.initialization_in_accounting)
            reservation_info['permission_scope'] = experiment_allowed.permission_scope
            reservation_info['permission_id']    = experiment_allowed.permission_id

            status, reservation_id    = self._coordinator.reserve_experiment(
                    experiment_allowed.experiment.to_experiment_id(),
                    time_allowed,
                    priority,
                    initialization_in_accounting,
                    client_initial_data,
                    reservation_info,
                    consumer_data
                )
        except coord_exc.ExperimentNotFoundError:
            raise core_exc.NoAvailableExperimentFoundError(
                "No experiment of type <%s,%s> is currently deployed" % (
                        experiment_id.exp_name,
                        experiment_id.cat_name
                    )
            )


        self._session['reservation_information'].pop('from_ip', None)
        self._session['reservation_id']   = reservation_id

        return status
dataset/ETHPy150Open weblabdeusto/weblabdeusto/server/src/weblab/core/user_processor.py/UserProcessor.reserve_experiment