def setup_db(host, port): db_connection = get_app_context().db_connection try: db_connection.connect(host, port) except Exception as e: print "DB connection failed (%s:%d)" %host %port raise e get_app_context().user_dao.init() logging.basicConfig(format='%(asctime)-15s %(message)s') db_logger = logging.getLogger("humongolus") orm.settings(db_logger, get_app_context().db_connection.get_connection())
def setup_server(host, port): server = SimpleFrontControllerHTTPServer((host, port)) users_controller = get_app_context().users_controller server.bind_controller("/user/create", users_controller, 'create_user') server.bind_controller("/user/follow", users_controller, 'follow_user') server.bind_controller("/user/unfollow", users_controller, 'unfollow_user') server.bind_controller("/user/tweet", users_controller, 'post_message') server.bind_controller("/user/tweets/get", users_controller, 'get_global_feed') server.bind_controller("/tweets/get", users_controller, 'get_user_feed') return server