'This is called by render_POST when the client requests an init
mode operation (at startup)
Args:
request (Request): Incoming request.'

def mode_init(self, request):

    csessid = request.args.get('csessid')[0]
    remote_addr = request.getClientIP()
    host_string = ('%s    (%s:%s)' % (_SERVERNAME, request.getRequestHostname(), request.getHost().port))
    sess = WebClientSession()
    sess.client = self
    sess.init_session('ajax/comet', remote_addr, self.sessionhandler)
    sess.csessid = csessid
    csession = _CLIENT_SESSIONS(session_key=sess.csessid)
    uid = (csession and csession.get('logged_in', False))
    if uid:
        sess.uid = uid
        sess.logged_in = True
    sess.sessionhandler.connect(sess)
    self.last_alive[csessid] = (time.time(), False)
    if (not self.keep_alive):
        self.keep_alive = LoopingCall(self._keepalive)
        self.keep_alive.start(_KEEPALIVE, now=False)
    return jsonify({'msg': host_string, 'csessid': csessid})
