parameters: (self)
return_statement: return environ
docstring: Returns a WSGI environment.
docstring_summary: Returns a WSGI environment.
docstring_tokens: Returns a WSGI environment .
function: def get_environment(self):
          """Returns a WSGI environment."""
          environ = self.environ
          if environ is not None:
              # Return the cached copy.
              return environ
  
          request = self.request
          path = request.path
          channel = self.channel
          server = channel.server
  
          path = path.lstrip('/')
  
          url_prefix_with_slash = server.adj.url_prefix.lstrip('/') + '/'
  
          if url_prefix_with_slash and path.startswith(url_prefix_with_slash):
              path = path[len(url_prefix_with_slash):]
  
          environ = {}
          environ['REQUEST_METHOD'] = request.command.upper()
          environ['SERVER_PORT'] = str(server.effective_port)
          environ['SERVER_NAME'] = server.server_name
          environ['SERVER_SOFTWARE'] = server.adj.ident
          environ['SERVER_PROTOCOL'] = 'HTTP/%s' % self.version
          environ['SCRIPT_NAME'] = server.adj.url_prefix
          environ['PATH_INFO'] = '/' + path
          environ['QUERY_STRING'] = request.query
          environ['REMOTE_ADDR'] = channel.addr[0]
  
          for key, value in request.headers.items():
              value = value.strip()
              mykey = rename_headers.get(key, None)
              if mykey is None:
                  mykey = 'HTTP_%s' % key
              if mykey not in environ:
                  environ[mykey] = value
  
          # the following environment variables are required by the WSGI spec
          environ['wsgi.version'] = (1, 0)
          environ['wsgi.url_scheme'] = request.url_scheme
          environ['wsgi.errors'] = sys.stderr # apps should use the logging module
          environ['wsgi.multithread'] = True
          environ['wsgi.multiprocess'] = False
          environ['wsgi.run_once'] = False
          environ['wsgi.input'] = request.get_body_stream()
          environ['wsgi.file_wrapper'] = ReadOnlyFileBasedBuffer
  
          self.environ = environ
          return environ
function_tokens: def get_environment ( self ) : environ = self . environ if environ is not None : # Return the cached copy. return environ request = self . request path = request . path channel = self . channel server = channel . server path = path . lstrip ( '/' ) url_prefix_with_slash = server . adj . url_prefix . lstrip ( '/' ) + '/' if url_prefix_with_slash and path . startswith ( url_prefix_with_slash ) : path = path [ len ( url_prefix_with_slash ) : ] environ = { } environ [ 'REQUEST_METHOD' ] = request . command . upper ( ) environ [ 'SERVER_PORT' ] = str ( server . effective_port ) environ [ 'SERVER_NAME' ] = server . server_name environ [ 'SERVER_SOFTWARE' ] = server . adj . ident environ [ 'SERVER_PROTOCOL' ] = 'HTTP/%s' % self . version environ [ 'SCRIPT_NAME' ] = server . adj . url_prefix environ [ 'PATH_INFO' ] = '/' + path environ [ 'QUERY_STRING' ] = request . query environ [ 'REMOTE_ADDR' ] = channel . addr [ 0 ] for key , value in request . headers . items ( ) : value = value . strip ( ) mykey = rename_headers . get ( key , None ) if mykey is None : mykey = 'HTTP_%s' % key if mykey not in environ : environ [ mykey ] = value # the following environment variables are required by the WSGI spec environ [ 'wsgi.version' ] = ( 1 , 0 ) environ [ 'wsgi.url_scheme' ] = request . url_scheme environ [ 'wsgi.errors' ] = sys . stderr # apps should use the logging module environ [ 'wsgi.multithread' ] = True environ [ 'wsgi.multiprocess' ] = False environ [ 'wsgi.run_once' ] = False environ [ 'wsgi.input' ] = request . get_body_stream ( ) environ [ 'wsgi.file_wrapper' ] = ReadOnlyFileBasedBuffer self . environ = environ return environ