def render(self, request):
        script_name = "/"+string.join(request.prepath, '/')
        serverName = string.split(request.getRequestHostname(), ':')[0]
        env = {"SERVER_SOFTWARE":   server.version,
               "SERVER_NAME":       serverName,
               "GATEWAY_INTERFACE": "CGI/1.1",
               "SERVER_PROTOCOL":   request.clientproto,
               "SERVER_PORT":       str(request.getHost().port),
               "REQUEST_METHOD":    request.method,
               "SCRIPT_NAME":       script_name, # XXX
               "SCRIPT_FILENAME":   self.filename,
               "REQUEST_URI":       request.uri,
        }

        client = request.getClient()
        if client is not None:
            env['REMOTE_HOST'] = client
        ip = request.getClientIP()
        if ip is not None:
            env['REMOTE_ADDR'] = ip
        pp = request.postpath
        if pp:
            env["PATH_INFO"] = "/"+string.join(pp, '/')

        if hasattr(request, "content"):
            # request.content is either a StringIO or a TemporaryFile, and
            # the file pointer is sitting at the beginning (seek(0,0))
            request.content.seek(0,2)
            length = request.content.tell()
            request.content.seek(0,0)
            env['CONTENT_LENGTH'] = str(length)

        qindex = string.find(request.uri, '?')
        if qindex != -1:
            qs = env['QUERY_STRING'] = request.uri[qindex+1:]
            if '=' in qs:
                qargs = []
            else:
                qargs = [urllib.unquote(x) for x in qs.split('+')]
        else:
            env['QUERY_STRING'] = ''
            qargs = []

        # Propogate HTTP headers
        for title, header in request.getAllHeaders().items():
            envname = string.upper(string.replace(title, '-', '_'))
            if title not in ('content-type', 'content-length'):
                envname = "HTTP_" + envname
            env[envname] = header
        # Propogate our environment
        for key, value in os.environ.items():
            if not env.has_key(key):
                env[key] = value
        # And they're off!
        self.runProcess(env, request, qargs)
        return server.NOT_DONE_YET
Do various things to conform to the CGI specification.
dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/web/twcgi.py/CGIScript.render