Esempio n. 1
0
def make_app(global_conf, full_stack=True, **app_conf):
    """
    Set tg2-raptorized up with the settings found in the PasteDeploy configuration
    file used.
    
    :param global_conf: The global settings for tg2-raptorized (those
        defined under the ``[DEFAULT]`` section).
    :type global_conf: dict
    :param full_stack: Should the whole TG2 stack be set up?
    :type full_stack: str or bool
    :return: The tg2-raptorized application with all the relevant middleware
        loaded.
    
    This is the PasteDeploy factory for the tg2-raptorized application.
    
    ``app_conf`` contains all the application-specific settings (those defined
    under ``[app:main]``.
    
   
    """
    app = make_base_app(global_conf, full_stack=True, **app_conf)

    # Wrap your base TurboGears 2 application with custom middleware here
    app = raptorizemw.make_middleware(app)

    return app
Esempio n. 2
0
def make_app(global_conf, full_stack=True, **app_conf):
    """
    Set tg2-raptorized up with the settings found in the PasteDeploy configuration
    file used.
    
    :param global_conf: The global settings for tg2-raptorized (those
        defined under the ``[DEFAULT]`` section).
    :type global_conf: dict
    :param full_stack: Should the whole TG2 stack be set up?
    :type full_stack: str or bool
    :return: The tg2-raptorized application with all the relevant middleware
        loaded.
    
    This is the PasteDeploy factory for the tg2-raptorized application.
    
    ``app_conf`` contains all the application-specific settings (those defined
    under ``[app:main]``.
    
   
    """
    app = make_base_app(global_conf, full_stack=True, **app_conf)
    
    # Wrap your base TurboGears 2 application with custom middleware here
    app = raptorizemw.make_middleware(app)
    
    return app
Esempio n. 3
0
def init_app(app):
    app.wsgi_app = make_middleware(
        app.wsgi_app,
        random_chance=app.config.get("RAPTOR_CHANCE", 1.0),
        only_on_april_1st=app.config.get("RAPTOR_FOOLS", False),
        enterOn=app.config.get("RAPTOR_TRIGGER", "timer"),
        delayTime=app.config.get("RAPTOR_DELAY", 2000),
        serve_resources=True,
    )
    return app
Esempio n. 4
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    initialize_sql(engine)
    config = Configurator(settings=settings)
    config.add_static_view('static', 'pyramidraptorized:static', cache_max_age=3600)
    config.add_route('home', '/')
    config.add_view('pyramidraptorized.views.my_view',
                    route_name='home',
                    renderer='templates/mytemplate.pt')
    app = config.make_wsgi_app()
    app = raptorizemw.make_middleware(app)
    return app
Esempio n. 5
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    initialize_sql(engine)
    config = Configurator(settings=settings)
    config.add_static_view('static',
                           'pyramidraptorized:static',
                           cache_max_age=3600)
    config.add_route('home', '/')
    config.add_view('pyramidraptorized.views.my_view',
                    route_name='home',
                    renderer='templates/mytemplate.pt')
    app = config.make_wsgi_app()
    app = raptorizemw.make_middleware(app)
    return app
Esempio n. 6
0
#!/usr/bin/env python

from raptorizemw import make_middleware
import weberror.errormiddleware

if __name__ == '__main__':

    def app(environ, start_response):
        start_response('200 OK', [('Content-Type', 'text/html')])
        return ["<html><body>This is a simple app.</body></html>"]

    # Raptorize!
    app = make_middleware(
        app,
        delayTime=500,
        enterOn='konami-code',
    )

    # Debugging information!
    app = weberror.errormiddleware.ErrorMiddleware(app, debug=True)

    from wsgiref.simple_server import make_server
    httpd = make_server('localhost', 8081, app)
    try:
        print "Serving at localhost:8081..."
        httpd.serve_forever()
    except KeyboardInterrupt:
        print '^C'
Esempio n. 7
0
#!/usr/bin/env python

from raptorizemw import make_middleware
import weberror.errormiddleware

if __name__ == '__main__':
    def app(environ, start_response):
        start_response('200 OK', [('Content-Type', 'text/html')])
        return ["<html><body>This is a simple app.</body></html>"]

    # Raptorize!
    app = make_middleware(
        app,
        delayTime=500,
        enterOn='konami-code',
    )

    # Debugging information!
    app = weberror.errormiddleware.ErrorMiddleware(app, debug=True)

    from wsgiref.simple_server import make_server
    httpd = make_server('localhost', 8081, app)
    try:
        print "Serving at localhost:8081..."
        httpd.serve_forever()
    except KeyboardInterrupt:
        print '^C'