Ejemplo n.º 1
0
 def stop(self):
     """End the current active session.
     """
     request = getRequest()
     if "euphorie.session" in request.other:
         del request.other["euphorie.session"]
     deleteCookie(request.response, SESSION_COOKIE)
Ejemplo n.º 2
0
 def stop(self):
     """End the current active session.
     """
     request = getRequest()
     if "euphorie.session" in request.other:
         del request.other["euphorie.session"]
     deleteCookie(request.response, SESSION_COOKIE)
     setCookie(request.response, getSecret(), SESSION_COOKIE, '')
Ejemplo n.º 3
0
    def resume(self, session):
        """Activate the given session.

        :param session: session to activate
        :type session: :py:class:`euphorie.client.model.SurveySession`
        """
        request = getRequest()
        request.other["euphorie.session"] = session
        setCookie(request.response, getSecret(), SESSION_COOKIE, session.id)
Ejemplo n.º 4
0
    def resume(self, session):
        """Activate the given session.

        :param session: session to activate
        :type session: :py:class:`euphorie.client.model.SurveySession`
        """
        account = aq_base(getSecurityManager().getUser())
        if session.account is not account:
            raise ValueError('Can only resume session for current user.')

        request = getRequest()
        request.other["euphorie.session"] = session
        setCookie(request.response, getSecret(), SESSION_COOKIE, session.id)
Ejemplo n.º 5
0
    def resume(self, session):
        """Activate the given session.

        :param session: session to activate
        :type session: :py:class:`euphorie.client.model.SurveySession`
        """
        account = aq_base(getSecurityManager().getUser())
        if session.account is not account:
            raise ValueError('Can only resume session for current user.')

        request = getRequest()
        request.other["euphorie.session"] = session
        setCookie(request.response, getSecret(), SESSION_COOKIE, session.id)
Ejemplo n.º 6
0
 def _get_view(self, name, obj, survey_session=None, client=None):
     """Get's a view with a proper fresh request.
     If survey_session is set the SessionManager will be configured
     """
     old_request = getRequest()
     request = self.get_client_request(client=client)
     if survey_session is not None:
         request.other["euphorie.session"] = survey_session
     try:
         setRequest(request)
         yield api.content.get_view(name, obj, request)
     finally:
         setRequest(old_request)
Ejemplo n.º 7
0
    def start(self, title, survey, account=None):
        """Create a new session and activate it.

        :param title: title for the new session.
        :type title: unicode
        :param survey: survey for which the session is being created
        :type survey: :py:class:`euphorie.content.survey.Survey`
        :rtype: :py:class:`euphorie.client.model.SurveySession` instance
        """
        survey_session = create_survey_session(title, survey, account)
        request = getRequest()
        setCookie(request.response, getSecret(), SESSION_COOKIE,
                survey_session.id)
        request.other['euphorie.session'] = survey_session
        return survey_session
Ejemplo n.º 8
0
    def start(self, title, survey, account=None):
        """Create a new session and activate it.

        :param title: title for the new session.
        :type title: unicode
        :param survey: survey for which the session is being created
        :type survey: :py:class:`euphorie.content.survey.Survey`
        :rtype: :py:class:`euphorie.client.model.SurveySession` instance
        """
        survey_session = create_survey_session(title, survey, account)
        request = getRequest()
        setCookie(request.response, getSecret(), SESSION_COOKIE,
                  survey_session.id)
        request.other['euphorie.session'] = survey_session
        return survey_session
Ejemplo n.º 9
0
    def id(self):
        """The id of the current session, or None if there is no active
        session.

        :rtype: int or None
        """
        request = getRequest()
        if "euphorie.session" in request.other:
            return request.other["euphorie.session"].id

        session_id = getCookie(request, getSecret(), "_eu_session")

        try:
            return int(session_id)
        except TypeError:
            return None
Ejemplo n.º 10
0
    def session(self):
        """The current active client session. If no session is active None
        is returned.

        :rtype: :py:class:`euphorie.client.model.SurveySession` or None
        """
        request = getRequest()
        if "euphorie.session" in request.other:
            return request.other["euphorie.session"]

        id = self.id
        if id is None:
            return None

        session = Session.query(model.SurveySession).get(id)
        request.other["euphorie.session"] = session
        return session
Ejemplo n.º 11
0
    def session(self):
        """The current active client session. If no session is active None
        is returned.

        :rtype: :py:class:`euphorie.client.model.SurveySession` or None
        """
        request = getRequest()
        if "euphorie.session" in request.other:
            return request.other["euphorie.session"]

        id = self.id
        if id is None:
            return None

        session = Session.query(model.SurveySession).get(id)
        request.other["euphorie.session"] = session
        return session
Ejemplo n.º 12
0
    def id(self):
        """The id of the current session, or None if there is no active
        session.

        This method does not perform any security checks.

        :rtype: int or None
        """
        request = getRequest()
        if "euphorie.session" in request.other:
            return request.other["euphorie.session"].id

        session_id = getCookie(request, getSecret(), "_eu_session")

        try:
            return int(session_id)
        except TypeError:
            return None