Ticket #5004: replace-string-module-web-5004.patch

File replace-string-module-web-5004.patch, 3.0 KB (added by Jonathan Ballet, 9 years ago)
  • twisted/web/server.py

    diff --git twisted/web/server.py twisted/web/server.py
    index bc3f07c..f76d3e8 100644
    infrastructure. 
    1010from __future__ import division, absolute_import
    1111
    1212import warnings
    13 import string
    1413import types
    1514import copy
    1615import os
  • twisted/web/twcgi.py

    diff --git twisted/web/twcgi.py twisted/web/twcgi.py
    index 5ab580d..1298b48 100644
    I hold resource classes and helper classes that deal with CGI scripts. 
    88"""
    99
    1010# System Imports
    11 import string
    1211import os
    1312import urllib
    1413
    class CGIScript(resource.Resource): 
    6867        @type request: L{twisted.web.http.Request}
    6968        @param request: An HTTP request.
    7069        """
    71         script_name = "/"+string.join(request.prepath, '/')
    72         serverName = string.split(request.getRequestHostname(), ':')[0]
     70        script_name = "/" + "/".join(request.prepath)
     71        serverName = request.getRequestHostname().split(':')[0]
    7372        env = {"SERVER_SOFTWARE":   server.version,
    7473               "SERVER_NAME":       serverName,
    7574               "GATEWAY_INTERFACE": "CGI/1.1",
    class CGIScript(resource.Resource): 
    8988            env['REMOTE_ADDR'] = ip
    9089        pp = request.postpath
    9190        if pp:
    92             env["PATH_INFO"] = "/"+string.join(pp, '/')
     91            env["PATH_INFO"] = "/" + "/".join(pp)
    9392
    9493        if hasattr(request, "content"):
    9594            # request.content is either a StringIO or a TemporaryFile, and
    class CGIScript(resource.Resource): 
    9998            request.content.seek(0,0)
    10099            env['CONTENT_LENGTH'] = str(length)
    101100
    102         qindex = string.find(request.uri, '?')
     101        qindex = request.uri.find('?')
    103102        if qindex != -1:
    104103            qs = env['QUERY_STRING'] = request.uri[qindex+1:]
    105104            if '=' in qs:
    class CGIScript(resource.Resource): 
    112111
    113112        # Propogate HTTP headers
    114113        for title, header in request.getAllHeaders().items():
    115             envname = string.upper(string.replace(title, '-', '_'))
     114            envname = title.replace('-', '_').upper()
    116115            if title not in ('content-type', 'content-length'):
    117116                envname = "HTTP_" + envname
    118117            env[envname] = header
  • twisted/web/util.py

    diff --git twisted/web/util.py twisted/web/util.py
    index 0c6cdb6..6dcb936 100644
    __all__ = [ 
    1212
    1313from cStringIO import StringIO
    1414import linecache
    15 import string
    1615import types
    1716
    1817from twisted.python.filepath import FilePath
    htmlReprTypes = {types.DictType: htmlDict, 
    200199
    201200
    202201def htmlIndent(snippetLine):
    203     ret = string.replace(string.replace(html.escape(string.rstrip(snippetLine)),
    204                                   '  ', ' '),
    205                    '\t', '        ')
     202    ret = html.escape(snippetLine.rstrip())\
     203            .replace('  ', ' ')\
     204            .replace('\t', '        ')
    206205    return ret
    207206
    208207