Example #1
0
 def __init__(self):
   environ = dict(os.environ.items())
   if not 'PATH_INFO' in environ:
     environ['PATH_INFO'] = environ['SCRIPT_URL']
   BaseCGIHandler.__init__(
     self, sys.stdin, sys.stdout.buffer, sys.stderr, environ,
     multithread=False, multiprocess=True
   )
Example #2
0
def main():
    environ = dict(os.environ.items())
    setup_testing_defaults(environ)
    for arg in sys.argv[1:]:
        i = arg.find('=')
        if i != -1:
            environ[arg[0:i].upper()] = arg[i + 1:]
    handler = BaseCGIHandler(sys.stdin, sys.stdout, sys.stderr, environ, multithread=True, multiprocess=False)
    handler.run(application)
Example #3
0
 def __init__(self, **kw):
     setup_testing_defaults(kw)
     BaseCGIHandler.__init__(self,
                             BytesIO(),
                             BytesIO(),
                             StringIO(),
                             kw,
                             multithread=True,
                             multiprocess=True)
Example #4
0
def runserver():
    """Lance un serveur wsgi de test, puis lui attribue l'application a
    lancer avec eventuellement le chainage de middleware
    """
    from pyson.middleware.error import HandleError
    from pyson.middleware.log import Log
    from pyson.middleware.session import Session  #se wrapp automatiquement avec cookie
    from pyson.middleware.force_auth import Force_auth
    from pyson.middleware.http_basic import Http_basic
    from pyson.middleware.formdata import Formdata
    from pyson.middleware.restriction import Middle as Restriction

    if os.environ.get("REQUEST_METHOD", ""):
        from wsgiref.handlers import BaseCGIHandler
        BaseCGIHandler(sys.stdin, sys.stdout, sys.stderr,
                       os.environ).run(urls.urls)
        print "-------------  Attention ---------------"
    else:
        import wsgiref
        from wsgiref.simple_server import WSGIServer, WSGIRequestHandler
        httpd = WSGIServer(('', int(context.conf["port"])), WSGIRequestHandler)

        wrapper = Session(Formdata((Restriction(urls.urls))))

        httpd.set_app(wrapper)

        print "Serving HTTP on %s port %s ..." % httpd.socket.getsockname()
        httpd.serve_forever()
Example #5
0
 def runCGI(self, input, output, errors, env, argv=()):
     from wsgiref.handlers import BaseCGIHandler
     BaseCGIHandler(input,
                    output,
                    errors,
                    env,
                    multithread=False,
                    multiprocess=True).run(self.subject)
Example #6
0
def run():
    import urls
    if os.environ.get('REQUEST_METHOD', ''):
        from wsgiref.handlers import BaseCGIHandler
        BaseCGIHandler(
            sys.stdin, sys.stdout, sys.stderr, os.environ).run(urls.urls)
    else:
        from wsgiref.simple_server import WSGIServer, WSGIRequestHandler
        httpd = WSGIServer(('', 8080), WSGIRequestHandler)
        httpd.set_app(urls.urls)
        print "Server HTTP on %s port %s..." % httpd.socket.getsockname()
        httpd.serve_forever()
Example #7
0
def run():
    import urls
    if os.environ.get("REQUEST_METHOD", ""):
        from wsgiref.handlers import BaseCGIHandler
        BaseCGIHandler(sys.stdin, sys.stdout, sys.stderr, os.environ) \
                .run(urls.load('urls.map'))
    else:
        os.environ = {}
        from wsgiref.simple_server import WSGIServer, WSGIRequestHandler
        httpd = WSGIServer(('', 8080), WSGIRequestHandler)
        httpd.set_app(urls.load('urls.map'))
        print "Serving HTTP on %s port %s ..." % httpd.socket.getsockname()
        httpd.serve_forever()
Example #8
0
def run():
    import urls
    if os.environ.get("REQUEST_METHOD", ""):
        from wsgiref.handlers import BaseCGIHandler
        f = file("log", "a")
        BaseCGIHandler(sys.stdin, sys.stdout, f, os.environ).run(urls.urls)
        f.close()
    else:
        from wsgiref.simple_server import WSGIServer, WSGIRequestHandler
        httpd = WSGIServer(('', 8080), WSGIRequestHandler)
        httpd.set_app(urls.urls)
        print "Serving HTTP on %s port %s ..." % httpd.socket.getsockname()
        httpd.serve_forever()
Example #9
0
def run():
    import urls

    if os.environ.get('REQUEST_METHOD', ''):
        from wsgiref.handlers import BaseCGIHandler
        BaseCGIHandler(sys.stdin, sys.stdout, sys.stderr,
                       os.environ).run(urls.urls)
    else:
        from wsgiref.simple_server import WSGIServer, WSGIRequestHandler
        httpd = WSGIServer(('', 8080), WSGIRequestHandler)
        httpd.set_app(urls.urls)
        host, port = httpd.socket.getsockname()[:2]
        print 'Serving HTTP on {0} port {1}...'.format(host, port)
        httpd.serve_forever()
Example #10
0
def run():
    """ run server """
    from users import urls
    if os.environ.get("REQUEST_METHOD", ""):
        from wsgiref.handlers import BaseCGIHandler
        BaseCGIHandler(sys.stdin, sys.stdout, sys.stderr,
                       os.environ).run(urls.urls)
    else:
        from wsgiref.simple_server import WSGIServer, WSGIRequestHandler
        from beaker.middleware import SessionMiddleware

        session_opts = {
            'session.type': 'file',
            'session.cookie_expires': True,
            'session.data_dir': 'var',
        }

        app = SessionMiddleware(urls.urls, session_opts)
        httpd = WSGIServer(('', 8080), WSGIRequestHandler)
        httpd.set_app(app)
        print "Serving HTTP on %s port %s ..." % httpd.socket.getsockname()
        httpd.serve_forever()
Example #11
0
 def testCGIEnviron(self):
     h = BaseCGIHandler(None,None,None,{})
     h.setup_environ()
     for key in 'wsgi.url_scheme', 'wsgi.input', 'wsgi.errors':
         self.assertIn(key, h.environ)
Example #12
0
 def __init__(self,**kw):
     setup_testing_defaults(kw)
     BaseCGIHandler.__init__(
         self, BytesIO(), BytesIO(), StringIO(), kw,
         multithread=True, multiprocess=True
     )
 def testCGIEnviron(self):
     h = BaseCGIHandler(None, None, None, {})
     h.setup_environ()
     for key in 'wsgi.url_scheme', 'wsgi.input', 'wsgi.errors':
         self.assertIn(key, h.environ)
Example #14
0
 def __init__(self, request):
     BaseCGIHandler.__init__(self, request.stdin, request.stdout,
                             request.stderr, request.environ)
Example #15
0
 def testCGIEnviron(self):
     h = BaseCGIHandler(None, None, None, {})
     h.setup_environ()
     for key in "wsgi.url_scheme", "wsgi.input", "wsgi.errors":
         self.assert_(h.environ.has_key(key))