예제 #1
0
파일: fcgi.py 프로젝트: ZoomQuiet/eurasia
def config(**args):
	handler = None
	for name in ('fcgihandler', 'controller' , 'handler' , 'wsgihandler'
	             'application', 'wsgi', 'app', 'wsgi_app', 'wsgi_application'):

		if name in args:
			if handler:
				raise TypeError('fcgi.config(): too many handlers')

			handler = name

	if not handler:
		raise TypeError('fcgi.config(): handler is required')

	elif handler in ('wsgi', 'app', 'application', 'wsgihandler',
	                 'wsgi_app'   , 'wsgi_application'):

		handler = wsgi(args[handler])
	else:
		handler = args[handler]

	if 'port' not in args and 'bind' not in args:
		globals()['ignore_cpus'] = True
		sockets = Sockets('fromfd:0')

	elif 'port' in args:
		sockets = Sockets([('0.0.0.0', args['port'])])
	else:
		sockets = Sockets(args['bind'])

	for sock, environ in sockets:
		TcpServer(sock, FcgiHandler(handler))
예제 #2
0
파일: fcgi.py 프로젝트: tempbottle/eurasia
def config(**args):
    handler = None
    for name in ('fcgihandler', 'controller', 'handler', 'wsgihandler'
                 'application', 'wsgi', 'app', 'wsgi_app', 'wsgi_application'):

        if name in args:
            if handler:
                raise TypeError('fcgi.config(): too many handlers')

            handler = name

    if not handler:
        raise TypeError('fcgi.config(): handler is required')

    elif handler in ('wsgi', 'app', 'application', 'wsgihandler', 'wsgi_app',
                     'wsgi_application'):

        handler = wsgi(args[handler])
    else:
        handler = args[handler]

    if 'port' not in args and 'bind' not in args:
        globals()['ignore_cpus'] = True
        sockets = Sockets('fromfd:0')

    elif 'port' in args:
        sockets = Sockets([('0.0.0.0', args['port'])])
    else:
        sockets = Sockets(args['bind'])

    for sock, environ in sockets:
        TcpServer(sock, FcgiHandler(handler))
예제 #3
0
파일: web.py 프로젝트: tempbottle/eurasia
def config(**args):
    handler = None
    for name in ('application', 'wsgi', 'app', 'wsgi_app', 'wsgi_application',
                 'httphandler', 'controller', 'handler', 'tcphandler',
                 'wsgihandler'):

        if name in args:
            if handler:
                raise TypeError('web.config(): too many handlers')

            handler = name

    if not handler:
        raise TypeError('web.config(): handler is required')

    elif handler in ('wsgi', 'app', 'application', 'wsgihandler', 'wsgi_app',
                     'wsgi_application'):

        handler = wsgi(args[handler])
    else:
        handler = args[handler]

    if 'port' in args and 'bind' in args:
        raise TypeError('too many addresses')

    if 'port' in args:
        sockets = Sockets([('0.0.0.0', int(args['port']))], **args)
    elif 'bind' in args:
        sockets = Sockets(args['bind'], **args)
    else:
        sockets = Sockets([('0.0.0.0', 8080)], **args)

    if 'tcphandler' in args:
        for sock, environ in sockets:
            TcpServer(sock, TcpHandler(handler))
    else:
        for sock, environ in sockets:
            TcpServer(sock, HttpHandler(handler, **environ))
예제 #4
0
파일: web.py 프로젝트: ZoomQuiet/eurasia
def config(**args):
	handler = None
	for name in ('application', 'wsgi', 'app', 'wsgi_app', 'wsgi_application',
	 'httphandler', 'controller' , 'handler' , 'tcphandler', 'wsgihandler'):

		if name in args:
			if handler:
				raise TypeError('web.config(): too many handlers')

			handler = name

	if not handler:
		raise TypeError('web.config(): handler is required')

	elif handler in ('wsgi', 'app', 'application', 'wsgihandler',
	                     'wsgi_app'   , 'wsgi_application'):

		handler = wsgi(args[handler])
	else:
		handler = args[handler]

	if 'port' in args and 'bind' in args:
		raise TypeError('too many addresses')

	if   'port' in args:
		sockets = Sockets([('0.0.0.0', int(args['port']))], **args)
	elif 'bind' in args:
		sockets = Sockets(args['bind'], **args)
	else:
		sockets = Sockets([('0.0.0.0', 8080)], **args)

	if 'tcphandler' in args:
		for sock, environ in sockets:
			TcpServer(sock,  TcpHandler(handler))
	else:
		for sock, environ in sockets:
			TcpServer(sock, HttpHandler(handler, **environ))