Exemplo n.º 1
0
def test_restorer_basic_manager_outside():
    data = _restorer_data()[0]
    wsgiapp = RegistryUsingApp(data[0], data[1], raise_exc=Exception())
    wsgiapp = EvalException(wsgiapp)
    wsgiapp = RegistryManager(wsgiapp)
    _set_cleanup_test(data)
    _test_restorer(wsgiapp, [data])
Exemplo n.º 2
0
def test_restorer_middleman_nested_evalexception():
    data = _restorer_data()[:2]
    wsgiapp = RegistryUsingApp(data[0][0], data[0][1], raise_exc=Exception())
    wsgiapp = EvalException(wsgiapp)
    wsgiapp = RegistryMiddleMan(wsgiapp, data[1][0], data[1][1], 0)
    wsgiapp = RegistryManager(wsgiapp)
    _set_cleanup_test(data[1])
    _test_restorer(wsgiapp, data)
Exemplo n.º 3
0
def wrap_wsgi_debug(app, conf):
    conf.base_config.debug_mode = True
    try:
        from werkzeug.debug import DebuggedApplication
        app = DebuggedApplication(app, evalex=True)
    except ImportError:
        try:
            from paste.evalexception.middleware import EvalException
            app = EvalException(app)
        except ImportError:
            print('Error: Install Werkzeug or Paste for browser-based debugging.')

    return app

def app(environ, start_response):
    # Except error
    if 'error' in environ['PATH_INFO'].lower():
        raise Exception('Detect "error" in URL path')

    # Session
    session = environ.get('paste.session.factory', lambda: {})()
    if 'count' in session:
        count = session['count']
    else:
        count = 1
    session['count'] = count + 1

    # Generate response
    start_response('200 OK', [('Content-Type', 'text/plain')])
    return ['You have been here %d times!\n' % count, ]

app = EvalException(app)   # go to http://localhost:8000/Errors
app = SessionMiddleware(app)
app = GzipMiddleware(app)
app = PonyMiddleware(app)  # go to http://localhost:8000/pony

if __name__ == '__main__':
    from paste import reloader
    from paste.httpserver import serve

    reloader.install()
    serve(app, host='0.0.0.0', port=8000)
Exemplo n.º 5
0
                                  ignore_warnings=ignore_config_warnings)
        services = conf.configured_services()
    except ConfigurationError, e:
        log.fatal(e)
        raise

    app = MapProxyApp(services, conf.base_config)
    if debug:
        conf.base_config.debug_mode = True
        try:
            from werkzeug.debug import DebuggedApplication
            app = DebuggedApplication(app, evalex=True)
        except ImportError:
            try:
                from paste.evalexception.middleware import EvalException
                app = EvalException(app)
            except ImportError:
                print 'Error: Install Werkzeug or Paste for browser-based debugging.'
    return app


class MapProxyApp(object):
    """
    The MapProxy WSGI application.
    """
    handler_path_re = re.compile('^/(\w+)')

    def __init__(self, services, base_config):
        self.handlers = {}
        self.base_config = base_config
        for service in services:
Exemplo n.º 6
0
def get_info(environ, start_response):
    #    command = dict(parse_querystring(environ)).get('command','')
    page = str(parse_querystring(environ))

    #    if command == 'clear':
    #        if 'REMOTE_USER' in environ:
    #            del environ['REMOTE_USER']
    #        if 'REMOTE_SESSION' in environ:
    #            del environ['REMOTE_SESSION']
    #    else:
    #        environ['REMOTE_SESSION'] = authfunc(environ, my_realm, environ['REMOTE_USER'] )

    #    if environ.get('REMOTE_USER'):
    #        page = '<html><body>Welcome %s (%s)</body></html>'
    #        page %= (environ['REMOTE_USER'], environ['REMOTE_SESSION'])
    #    else:
    #        page = ('<html><body><form><input name="user" />'
    #                '<input type="submit" /></form></body></html>')
    return DataApp(page, content_type="text/plain")(environ, start_response)


root_app = URLMap()
root_app['/get_info'] = get_info

serve(EvalException(
    cookie_m.AuthCookieHandler(AuthDigestHandler(root_app, my_realm, authfunc),
                               secret="TEST2",
                               timeout=60)),
      host='0.0.0.0',
      port=8041)