Bind a new WSGI environment.

            This is done automatically for the global `bottle.request`
            instance on every request.
558714
def bind(self, environ):
        
        self.environ = environ
        # These attributes are used anyway, so it is ok to compute them here
        self.path = '/' + environ.get('PATH_INFO', '/').lstrip('/')
        self.method = environ.get('REQUEST_METHOD', 'GET').upper()
408584
def add_environment(self, environ):
        
        if isinstance(environ, dict):
            self._environment.update(environ)
576221
def bind(self, environ, app=None):
        
        if isinstance(environ, Request): # Recycle already parsed content
            for key in self.__dict__: #TODO: Test this
                setattr(self, key, getattr(environ, key))
            self.app = app
            return
        self._GET = self._POST = self._GETPOST = self._COOKIES = None
        self._body = self._header = None
        self.environ = environ
        self.app = app
        # These attributes are used anyway, so it is ok to compute them here
        self.path = '/' + environ.get('PATH_INFO', '/').lstrip('/')
        self.method = environ.get('REQUEST_METHOD', 'GET').upper()
574494
def bind_client(self, new):
        """"""
        top = self._stack[-1]
        self._stack[-1] = (new, top[1])
515013
def _base_environ(self, **request):
        '''
            
        '''
        # This is a minimal valid WSGI environ dictionary, plus:
        # - HTTP_COOKIE: for cookie support,
        # - REMOTE_ADDR: often useful, see #8551.
        # See http://www.python.org/dev/peps/pep-3333/#environ-variables

        environ = {
            'HTTP_COOKIE': self.cookies.output(header='', sep='; '),
            'PATH_INFO': str('/'),
            'REMOTE_ADDR': str('127.0.0.1'),
            'REQUEST_METHOD': str('GET'),
            'SCRIPT_NAME': str(''),
            'SERVER_NAME': str('localhost'),
            'SERVER_PORT': str('8000'),
            'SERVER_PROTOCOL': str('HTTP/1.1'),
            'wsgi.version': (1, 0),
            'wsgi.url_scheme': str('http'),
            'wsgi.input': FakePayload(b''),
            'wsgi.errors': self.errors,
            'wsgi.multiprocess': True,
            'wsgi.multithread': True,
            'wsgi.run_once': False,
        }
        environ.update(self.defaults)
        environ.update(request)
        return environ
1111614
def bind_env(self, *input_):
        
        if len(input_) == 0:
            return "bind_env missing key to bind to"

        key = input_[0].lower()

        if len(input_) == 1:
            env_key = self._merge_with_env_prefix(key)
        else:
            env_key = input_[1]

        self._env[key] = env_key

        if self._key_delimiter in key:
            parts = input_[0].split(self._key_delimiter)
            env_info = {
                "path": parts[1:-1],
                "final_key": parts[-1],
                "env_key": env_key
            }

            if self._env.get(parts[0]) is None:
                self._env[parts[0]] = [env_info]
            else:
                self._env[parts[0]].append(env_info)

        return None
17591
def main(global_config, **settings):
    
    config = Configurator(settings=settings)

    includeme(config)
    return config.make_wsgi_app()
881628
def bind_to_env(self, bound_env):
        '''
        
        '''
        return self.__class__(self._scope, self._location,
                              path=self._path, host=self._host,
                              fragment=self._fragment,
                              ready=self._ready,
                              need_arguments=self._need_arguments,
                              finalize_params=self._finalize_params,
                              parent=self._parent,
                              bound_env=bound_env)
38760
def configure():
    
    import os
    from uwsgiconf.presets.nice import PythonSection

    FILE = os.path.abspath(__file__)
    port = 8000

    configurations = []

    for idx in range(2):

        alias = 'app_%s' % (idx + 1)

        section = PythonSection(
            # Automatically reload uWSGI if this file is changed.
            touch_reload=FILE,

            # To differentiate easily.
            process_prefix=alias,

            # Serve WSGI application (see above) from this very file.
            wsgi_module=FILE,

            # Custom WSGI callable for second app.
            wsgi_callable=alias,

            # One is just enough, no use in worker on every core
            # for this demo.
            workers=1,

        ).networking.register_socket(
            PythonSection.networking.sockets.http('127.0.0.1:%s' % port)
        )

        port += 1

        configurations.append(
            # We give alias for configuration to prevent clashes.
            section.as_configuration(alias=alias))

    return configurations
824551
def create_environment(self, environment):
        

        uri = 'api/v3/environment/'

        data = dict()
        data['environments'] = list()
        data['environments'].append(environment)

        return super(ApiEnvironment, self).post(uri, data)
713758
def init_app(self, app):
        '''
        '''
        self.app = app
        self._session_conf = app.config.get('BEAKER_SESSION', {
            'session.type': 'file',
            'session.data_dir': '/tmp/session/data',
            'session.lock_dir': '/tmp/session/lock'
        })
        app.wsgi_app = SessionMiddleware(app.wsgi_app, self._session_conf)
        app.session_interface = BeakerSessionInterface()
1076965
def setup_environment():
  
  absl.logging.set_verbosity(absl.logging.WARNING)

  # The default is HTTP/1.0 for some strange reason. If we don't use
  # HTTP/1.1 then a new TCP socket and Python thread is created for
  # each HTTP request. The tradeoff is we must always specify the
  # Content-Length header, or do chunked encoding for streaming.
  serving.WSGIRequestHandler.protocol_version = 'HTTP/1.1'
1099838
def create(self, environments):
        

        data = {'environments_vip': environments}
        uri = 'api/v3/environment-vip/'
        return super(ApiEnvironmentVip, self).post(uri, data)
484815
def _bind(self, _descriptor):
        

        # If the method has a default code, use it
        self._defcode = getattr(_descriptor.method, '_wsgi_code', 200)

        # Set up content type and serializer
        self.content_type, self.serializer = _descriptor.serializer(self.req)
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)
309464
def bind_to_instance(self, instance):
        
        self.binding = instance
        self.middleware.append(instance)
379511
def main(global_config, **settings):
    
    config = Configurator(settings=settings)
    config.set_session_factory(session_factory)
    config.include('pyramid_jinja2')
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('index', '/')
    config.add_route('attrs', '/attrs/')
    config.add_route('metadata', '/metadata/')
    config.scan()
    return config.make_wsgi_app()