Ejemplo n.º 1
0
def make_app():
    from webob import Response
    import static
    static_app = static.Cling(c.static_dir)
    if c.static_override:
        from paste.cascade import Cascade
        static_app = Cascade([static.Cling(c.static_override), static_app])

    docs_app = pathpopper_middleware(static.Cling(c.docs_dir))
    code_app = pathpopper_middleware(static.Cling(c.static_dir + "/js"), 2)

    register("^/docs/code/", code_app)
    register("^/docs/", docs_app)
    
    for location, directory in c.static_map.items():
        topop = 1 + location.count('/')
        more_static = pathpopper_middleware(static.Cling(directory), topop)
        register("^/%s/" % location, more_static)

    app = URLRelay(default=static_app)
    app = auth_tkt.AuthTKTMiddleware(app, c.secret, secure=c.secure_cookie, 
                include_ip=False, httponly=c.http_only_cookie,
                current_domain_cookie=True, wildcard_cookie=True)
    app = db_middleware(app)
    
    if c.log_requests_to_stdout:
        from paste.translogger import TransLogger
        app = TransLogger(app)
        
    app = scriptwrapper_middleware(app)
    return app
Ejemplo n.º 2
0
def make_app():
    from webob import Response
    import static
    static_app = static.Cling(c.static_dir)
    if c.static_override:
        from paste.cascade import Cascade
        static_app = Cascade([static.Cling(c.static_override), static_app])

    docs_app = pathpopper_middleware(static.Cling(c.docs_dir))
    code_app = pathpopper_middleware(static.Cling(c.static_dir + "/js"), 2)

    register("^/docs/code/", code_app)
    register("^/docs/", docs_app)

    for location, directory in c.static_map.items():
        topop = 1 + location.count('/')
        more_static = pathpopper_middleware(static.Cling(directory), topop)
        register("^/%s/" % location, more_static)

    app = URLRelay(default=static_app)
    app = auth_tkt.AuthTKTMiddleware(app,
                                     c.secret,
                                     secure=c.secure_cookie,
                                     include_ip=False,
                                     httponly=c.http_only_cookie,
                                     current_domain_cookie=True,
                                     wildcard_cookie=True)
    app = db_middleware(app)

    if c.log_requests_to_stdout:
        from paste.translogger import TransLogger
        app = TransLogger(app)

    app = scriptwrapper_middleware(app)
    return app
Ejemplo n.º 3
0
def make_app():
    from webob import Response
    import static
    static_app = static.Cling(c.static_dir)
    
    docs_app = pathpopper_middleware(static.Cling(c.docs_dir))
    code_app = pathpopper_middleware(static.Cling(c.static_dir + "/js"), 2)
    
    register("^/docs/code/", code_app)
    register("^/docs/", docs_app)
    
    app = URLRelay(default=static_app)
    app = auth_tkt.AuthTKTMiddleware(app, c.secret, secure=c.secure_cookie, 
                include_ip=False, httponly=True,
                current_domain_cookie=True, wildcard_cookie=True)
    app = db_middleware(app)
    
    if c.log_requests_to_stdout:
        from paste.translogger import TransLogger
        app = TransLogger(app)
        
    return app
Ejemplo n.º 4
0
    start_response('200 OK', [('Content-Type', 'text/plain')])
    args, kw = environ['wsgiorg.routing_args']
    return [' '.join(['PUT', args[0], args[1], kw['kwarg1'], kw['kwarg2']])]

@urlrelay.url(r'/spectest/', 'POST')
def meth_post(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/plain')])
    return ['Empty post']

@urlrelay.url(r'/spectest/(.*)', 'GET')
def meth_get2(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/plain')])
    args, kw = environ['wsgiorg.routing_args']
    return [' '.join(['GET', args[0]])]

urlrelay.register('^/notfound$', 'urlrelay._handler')
urlrelay.register('^/notfound2$', 'urlrelay._handler', 'GET')
urlrelay.register('^/notfound2$', 'urlrelay._handler', 'PUT')
urlrelay.register('^/notfound2$', 'urlrelay._handler', 'POST')
urlrelay.register('^/notfound4$', '_handler')
urlrelay.register('^/notfound3$', '_handler', 'GET')
urlrelay.register('^/notfound3$', '_handler', 'PUT')
urlrelay.register('^/notfound3$', '_handler', 'POST')

class UrlRelayTest(unittest.TestCase):      

    def test_inmem_root(self):
        '''Checks simple url.'''
        environ = {'PATH_INFO':'/', 'REQUEST_METHOD':'GET'}
        result = urlrelay.URLRelay()(environ, dummy_sr)
        self.assertEqual(result[0], 'index')