server

jsb tornado server code.

class fbf.tornado.server.BaseHandler(application, request, **kwargs)

Bases: tornado.web.RequestHandler

get_current_user()
class fbf.tornado.server.JSBLoop(*args)

Bases: tornado.ioloop.IOLoop

class fbf.tornado.server.TornadoServer(request_callback, no_keep_alive=False, io_loop=None, xheaders=False, ssl_options=None, **kwargs)

Bases: tornado.httpserver.HTTPServer

CODE

# fbf/tornado/server.py
#
#

""" jsb tornado server code.  """

jsb import

from fbf.imports import gettornado

tornado = gettornado()

tornado import

import tornado.ioloop
import tornado.httpserver
import tornado.web

basic imports

import logging

jsb specific ioloop

class JSBLoop(tornado.ioloop.IOLoop):

    def __init__(self, *args):
        logging.warn("using Select IOLoop.")
        tornado.ioloop.IOLoop.__init__(self, tornado.ioloop._Select(), *args)

server part

class TornadoServer(tornado.httpserver.HTTPServer):

    pass

class BaseHandler(tornado.web.RequestHandler):

    def get_current_user(self):
        user  = self.get_secure_cookie("user")
        if not user: user = "demouser" + "@" + self.request.remote_ip
        if user: return tornado.escape.xhtml_escape(user)

Table Of Contents

Previous topic

tornado

Next topic

utils

This Page