예제 #1
0
    def default(self, *args, **kwargs):
        cherrypy.log(pformat(kwargs), severity=logging.DEBUG)
        session_type = args[-1]

        if 'tagData' not in kwargs:
            raise cherrypy.HTTPError(400, 'Missing tagData argument')

        session_key = get_session_key(kwargs)

        with get_connection_from_pool() as conn:
            latest_session_data = self.update_session_tag(
                conn,
                session_type,
                session_key,
                kwargs['tagData'])

        cherrypy.log(str(latest_session_data), severity=logging.DEBUG)
        return latest_session_data.asDict()
예제 #2
0
    def default(self, *args, **kwargs):
        cherrypy.log(pformat(kwargs), severity=logging.DEBUG)
        session_type = args[-1]
        as_digest = get_session_key(kwargs)
        cherrypy.log('Hash digest: ' + as_digest, severity=logging.DEBUG)

        with get_connection_from_pool() as conn:
            existing_session_data = self.get_existing_session(
                conn,
                as_digest,
                session_type)
            cherrypy.log(
                'Existing session data: {}'.format(pformat(existing_session_data)),
                severity=logging.DEBUG)
            tag = kwargs['tagData'] if 'tagData' in kwargs \
                else None if existing_session_data is None \
                else existing_session_data['tag']

            if existing_session_data is None:
                latest_session_data = self.begin_new_session(
                    conn,
                    as_digest,
                    session_type,
                    tag)
            elif self.is_session_stale(conn, existing_session_data['session_id']):
                latest_session_data = self.recreate_session(
                    conn,
                    existing_session_data['session_id'],
                    as_digest,
                    session_type,
                    tag)
            else:
                latest_session_data = self.update_existing_session(
                    conn,
                    existing_session_data['session_id'],
                    tag)
                session_string = existing_session_data['session_string']

            cherrypy.log(str(latest_session_data), severity=logging.DEBUG)
            return latest_session_data.asDict()