This function returns a Pyramid WSGI application.
17591
def main(global_config, **settings):
    
    config = Configurator(settings=settings)

    includeme(config)
    return config.make_wsgi_app()
1269707
def engine(self):
        """"""
        return self.backend({
            'APP_DIRS': True,
            'DIRS': [str(ROOT / self.backend.app_dirname)],
            'NAME': 'djangoforms',
            'OPTIONS': {},
        })
806519
def from_caller_module_root():
        ''''''
        import inspect
        all_stack = list(inspect.stack())
        curframe = inspect.currentframe()
        calframe = inspect.getouterframes(curframe, 2)
        module = inspect.getmodule(calframe[1].frame)
        if not module:
            raise RuntimeError('caller is not a module')
        root_module_name = module.__name__.partition('.')[0]
        fullpath = sys.modules[root_module_name].__file__
        return Path(fullpath)
1334060
def tilequeue_enqueue_full_pyramid_from_toi(cfg, peripherals, args):
    """"""
    logger = make_logger(cfg, 'enqueue_tiles_of_interest')
    logger.info('Enqueueing tiles of interest')

    logger.info('Fetching tiles of interest ...')
    tiles_of_interest = peripherals.toi.fetch_tiles_of_interest()
    n_toi = len(tiles_of_interest)
    logger.info('Fetching tiles of interest ... done')

    rawr_yaml = cfg.yml.get('rawr')
    assert rawr_yaml, 'Missing rawr yaml'
    group_by_zoom = rawr_yaml.get('group-zoom')
    assert group_by_zoom, 'Missing rawr group-zoom'
    assert isinstance(group_by_zoom, int), 'Invalid rawr group-zoom'

    if args.zoom_start is None:
        zoom_start = group_by_zoom
    else:
        zoom_start = args.zoom_start

    if args.zoom_stop is None:
        zoom_stop = cfg.max_zoom + 1  # +1 because exclusive
    else:
        zoom_stop = args.zoom_stop

    assert zoom_start >= group_by_zoom
    assert zoom_stop > zoom_start

    ungrouped = []
    coords_at_group_zoom = set()
    for coord_int in tiles_of_interest:
        coord = coord_unmarshall_int(coord_int)
        if coord.zoom < zoom_start:
            ungrouped.append(coord)
        if coord.zoom >= group_by_zoom:
            coord_at_group_zoom = coord.zoomTo(group_by_zoom).container()
            coords_at_group_zoom.add(coord_at_group_zoom)

    pyramids = coord_pyramids(coords_at_group_zoom, zoom_start, zoom_stop)

    coords_to_enqueue = chain(ungrouped, pyramids)

    queue_writer = peripherals.queue_writer
    n_queued, n_in_flight = queue_writer.enqueue_batch(coords_to_enqueue)

    logger.info('%d enqueued - %d in flight' % (n_queued, n_in_flight))
    logger.info('%d tiles of interest processed' % n_toi)
1067272
def application
      return @app if @app
      
      @stack.use Rack::HtmlValidator if self.options[:validate]
      @stack.run Rack::HtmlMockup.new(self.project)
      
      @app = @stack
    end
1258526
def main(global_config, **settings):
    """"""
    engine = engine_from_config(settings, "sqlalchemy.")

    DBSession.configure(bind=engine)

    Base.metadata.bind = engine

    config = Configurator(settings=settings)

    config.include("pyramid_jinja2")

    config.include("pyramid_debugtoolbar")

    config.add_route("home", "/")

    config.add_route("data", "/data")

    config.add_route("data_advanced", "/data_advanced")

    config.add_route("data_yadcf", "/data_yadcf")

    config.add_route("dt_110x", "/dt_110x")

    config.add_route("dt_110x_custom_column", "/dt_110x_custom_column")

    config.add_route("dt_110x_basic_column_search",
                     "/dt_110x_basic_column_search")

    config.add_route("dt_110x_advanced_column_search",
                     "/dt_110x_advanced_column_search")

    config.add_route("dt_110x_yadcf", "/dt_110x_yadcf")

    config.scan()

    json_renderer = JSON()

    json_renderer.add_adapter(date, date_adapter)

    config.add_renderer("json_with_dates", json_renderer)

    config.add_jinja2_renderer('.html')

    return config.make_wsgi_app()
1294433
def wsgi_proxyfix(factory=None):
    
    def create_wsgi(app, **kwargs):
        wsgi_app = factory(app, **kwargs) if factory else app.wsgi_app
        if app.config.get('WSGI_PROXIES'):
            return ProxyFix(wsgi_app, num_proxies=app.config['WSGI_PROXIES'])
        return wsgi_app
    return create_wsgi
828416
def init_app(application):
    
    config = {k: v for k, v in application.config.items() if k in SCHEMA}

    kwargs = {'autorefresh': application.debug}

    kwargs.update((k[11:].lower(), v) for k, v in config.items())

    instance = whitenoise.WhiteNoise(application.wsgi_app, **kwargs)

    instance.add_files(application.static_folder, application.static_url_path)

    if not hasattr(application, 'extensions'):
        application.extensions = {}

    application.extensions['whitenoise'] = instance

    application.wsgi_app = instance
610958
def get_app(self):
        
        # First see to connection stack
        ctx = connection_stack.top
        if ctx is not None:
            return ctx.app

        # Next return app from instance cache
        if self.app is not None:
            return self.app

        # Something went wrong, in most cases app just not instantiated yet
        # and we cannot locate it
        raise RuntimeError(
            'Flask application not registered on Redis instance '
            'and no applcation bound to current context')
854485
def strip_wsgi(request):
    """"""

    meta = copy(request.META)
    for key in meta:
        if key[:4] == 'wsgi':
            meta[key] = None
    return meta
753113
def setup(self, environ):
        ''''''
        json_handler = Root().putSubHandler('calc', Calculator())
        middleware = wsgi.Router('/', post=json_handler,
                                 accept_content_types=JSON_CONTENT_TYPES)
        response = [wsgi.GZipMiddleware(200)]
        return wsgi.WsgiHandler(middleware=[wsgi.wait_for_body_middleware,
                                            middleware],
                                response_middleware=response)
690553
def home(request):
    """"""
    try:
        DBSession.query(User).first()
    except DBAPIError:
        return Response(
            conn_err_msg,
            content_type="text/plain",
            status_int=500,
        )

    return {"project": "pyramid_tut"}
344369
def website(app=None, mode='home', subcontext='UserGuide'):
    
    base_url = WEBSITES.get(mode, '')

    if app and base_url:
        opts = {'app': app, 'base_url': base_url}
        base_url = SUBCONTEXT_MAP.get((mode, subcontext), base_url)
        base_url %= opts

    return base_url
627023
def main(global_settings, **settings):
    """"""
    my_session_factory = SignedCookieSessionFactory('itsaseekreet')
    # Add session engine
    config = Configurator(
        settings=settings,
        session_factory=my_session_factory
    )
    # Add static and templates
    config.add_static_view(name='static', path='static')
    config.include('pyramid_jinja2')
    config.add_jinja2_search_path('templates')
    config.include('ps_crud')

    # Setting up pyramid_sacrud
    config.include('pyramid_sacrud', route_prefix='admin')
    settings = config.get_settings()
    settings['pyramid_sacrud.models'] = (
        ('Docker', [Image(), ]),
    )

    # Make app
    config.scan('views')
    return config.make_wsgi_app()
220454
def create(self):
        """"""
        # url('layertemplates')
        content = request.environ['wsgi.input'].read(int(request.environ['CONTENT_LENGTH']))
        content = content.decode('utf8')
        content = simplejson.loads(content)
        lt = self._new_lt_from_user(content['name'], content['comment'], content['json'], c.user)
        response.status = 201
        href = h.url_for(controller="layertemplates", action="show", id=lt.id)
        return {'name': lt.name, 'comment': lt.comment, 'id': lt.id, 'href': href}
320380
def make_wsgi_app(registry=REGISTRY):
    """"""

    def prometheus_app(environ, start_response):
        params = parse_qs(environ.get('QUERY_STRING', ''))
        r = registry
        encoder, content_type = choose_encoder(environ.get('HTTP_ACCEPT'))
        if 'name[]' in params:
            r = r.restricted_registry(params['name[]'])
        output = encoder(r)

        status = str('200 OK')
        headers = [(str('Content-type'), content_type)]
        start_response(status, headers)
        return [output]

    return prometheus_app
1040142
def make_urldispatch_application(_, **settings):
    
    patterns = [p.split("=", 1)
                for p in settings['patterns'].split('\n')
                if p]
    application = URLDispatcher()

    for pattern, app in patterns:
        pattern = pattern.strip()
        app = app.strip()
        mod, obj = app.split(":", 1)
        if mod not in sys.modules:
            __import__(mod)
        mod = sys.modules[mod]
        obj = getattr(mod, obj)
        application.add_url(app, pattern, obj)

    return application