openslides_backend/presenter/presenter.py
def parse_presenters(
        self, request: Request
    ) -> Tuple[PresenterResponse, Optional[str]]:
        """
        Parses presenter request send by client. Raises PresenterException
        if something went wrong.
        """
        self.logger.debug(
            f"Presenter map contains the following presenters: {presenters_map}."
        )
        presenters = []
        for presenter_blob in request.json:
            presenter = presenters_map.get(presenter_blob["presenter"])
            if presenter is None:
                raise PresenterException(
                    f"Presenter {presenter_blob['presenter']} does not exist."
                )
            presenters.append(presenter)

        if len(set(presenter.csrf_exempt for presenter in presenters)) > 1:
            raise PresenterException(
                "You cannot call presenters with different login mechanisms"
            )

        access_token: Optional[str] = None
        if presenters[0].csrf_exempt:
            user_id = self.services.authentication().authenticate_only_refresh_id(
                request.cookies
            )
        else:
            user_id, access_token = self.services.authentication().authenticate(
                request.headers, request.cookies
            )

        response = []
        for PresenterClass in presenters:
            presenter_instance = PresenterClass(
                presenter_blob.get("data"),
                self.services,
                self.datastore,
                self.logging,
                user_id,
            )
            presenter_instance.validate()
            with self.datastore.get_database_context():
                result = presenter_instance.get_result()
            response.append(result)
        self.logger.debug("Presenter data ready.")
        return response, access_token

        Parses presenter request send by client. Raises PresenterException
        if something went wrong.
        
Parses presenter request send by client. Raises PresenterException
if something went wrong.
Parses presenter request send by client . Raises PresenterException if something went wrong .
def parse_presenters(
        self, request: Request
    ) -> Tuple[PresenterResponse, Optional[str]]:
        self.logger.debug(
            f"Presenter map contains the following presenters: {presenters_map}."
        )
        presenters = []
        for presenter_blob in request.json:
            presenter = presenters_map.get(presenter_blob["presenter"])
            if presenter is None:
                raise PresenterException(
                    f"Presenter {presenter_blob['presenter']} does not exist."
                )
            presenters.append(presenter)
        if len(set(presenter.csrf_exempt for presenter in presenters)) > 1:
            raise PresenterException(
                "You cannot call presenters with different login mechanisms"
            )
        access_token: Optional[str] = None
        if presenters[0].csrf_exempt:
            user_id = self.services.authentication().authenticate_only_refresh_id(
                request.cookies
            )
        else:
            user_id, access_token = self.services.authentication().authenticate(
                request.headers, request.cookies
            )
        response = []
        for PresenterClass in presenters:
            presenter_instance = PresenterClass(
                presenter_blob.get("data"),
                self.services,
                self.datastore,
                self.logging,
                user_id,
            )
            presenter_instance.validate()
            with self.datastore.get_database_context():
                result = presenter_instance.get_result()
            response.append(result)
        self.logger.debug("Presenter data ready.")
        return response, access_token
def parse_presenters ( self , request : Request ) -> Tuple [ PresenterResponse , Optional [ str ] ] : self . logger . debug ( f"Presenter map contains the following presenters: {presenters_map}." ) presenters = [ ] for presenter_blob in request . json : presenter = presenters_map . get ( presenter_blob [ "presenter" ] ) if presenter is None : raise PresenterException ( f"Presenter {presenter_blob['presenter']} does not exist." ) presenters . append ( presenter ) if len ( set ( presenter . csrf_exempt for presenter in presenters ) ) > 1 : raise PresenterException ( "You cannot call presenters with different login mechanisms" ) access_token : Optional [ str ] = None if presenters [ 0 ] . csrf_exempt : user_id = self . services . authentication ( ) . authenticate_only_refresh_id ( request . cookies ) else : user_id , access_token = self . services . authentication ( ) . authenticate ( request . headers , request . cookies ) response = [ ] for PresenterClass in presenters : presenter_instance = PresenterClass ( presenter_blob . get ( "data" ) , self . services , self . datastore , self . logging , user_id , ) presenter_instance . validate ( ) with self . datastore . get_database_context ( ) : result = presenter_instance . get_result ( ) response . append ( result ) self . logger . debug ( "Presenter data ready." ) return response , access_token
Parses presenter request send by client.
Parses presenter request send by client .
"""
        Parses presenter request send by client. Raises PresenterException
        if something went wrong.
        """
self
request
Request