Commit 6c4b3aaf authored by Andreas Jung's avatar Andreas Jung

replace string module calls by string method calls

parent e0626a9b
...@@ -94,7 +94,7 @@ from ZPublisher.HTTPRequest import HTTPRequest ...@@ -94,7 +94,7 @@ from ZPublisher.HTTPRequest import HTTPRequest
from cStringIO import StringIO from cStringIO import StringIO
import os import os
from base64 import encodestring from base64 import encodestring
import string,re import re
class FTPRequest(HTTPRequest): class FTPRequest(HTTPRequest):
...@@ -192,7 +192,7 @@ class FTPRequest(HTTPRequest): ...@@ -192,7 +192,7 @@ class FTPRequest(HTTPRequest):
path=apply(os.path.join,args) path=apply(os.path.join,args)
path=os.path.normpath(path) path=os.path.normpath(path)
if os.sep != '/': if os.sep != '/':
path=string.replace(path,os.sep,'/') path=path.replace(os.sep,'/')
return path return path
......
...@@ -147,7 +147,6 @@ from FTPRequest import FTPRequest ...@@ -147,7 +147,6 @@ from FTPRequest import FTPRequest
from ZServer import CONNECTION_LIMIT, requestCloseOnExec from ZServer import CONNECTION_LIMIT, requestCloseOnExec
from cStringIO import StringIO from cStringIO import StringIO
import string
import os import os
from mimetypes import guess_type from mimetypes import guess_type
import marshal import marshal
...@@ -174,7 +173,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -174,7 +173,7 @@ class zope_ftp_channel(ftp_channel):
path=apply(os.path.join,args) path=apply(os.path.join,args)
path=os.path.normpath(path) path=os.path.normpath(path)
if os.sep != '/': if os.sep != '/':
path=string.replace(path,os.sep,'/') path=path.replace(os.sep,'/')
return path return path
# Overriden async_chat methods # Overriden async_chat methods
...@@ -210,7 +209,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -210,7 +209,7 @@ class zope_ftp_channel(ftp_channel):
# XXX clean this up, maybe with getopts # XXX clean this up, maybe with getopts
if len(line) > 1: if len(line) > 1:
args = string.split(line[1]) args = line[1].split()
else: else:
args =[] args =[]
path_args = [] path_args = []
...@@ -220,7 +219,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -220,7 +219,7 @@ class zope_ftp_channel(ftp_channel):
for i in range(len(args)): for i in range(len(args)):
x = args[i] x = args[i]
if string.find(x,'*')!=-1 or string.find(x,'?')!=-1: if x.find('*')!=-1 or x.find('?')!=-1:
self.globbing = x self.globbing = x
args[i] = '.' args[i] = '.'
...@@ -318,7 +317,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -318,7 +317,7 @@ class zope_ftp_channel(ftp_channel):
def cmd_mdtm(self, line): def cmd_mdtm(self, line):
'show last modification time of file' 'show last modification time of file'
if len (line) != 2: if len (line) != 2:
self.command.not_understood (string.join (line)) self.command.not_understood (' '.join(line))
return return
response=make_response(self, self.mdtm_completion) response=make_response(self, self.mdtm_completion)
request=FTPRequest(line[1],'MDTM',self,response) request=FTPRequest(line[1],'MDTM',self,response)
...@@ -345,7 +344,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -345,7 +344,7 @@ class zope_ftp_channel(ftp_channel):
def cmd_size(self, line): def cmd_size(self, line):
'return size of file' 'return size of file'
if len (line) != 2: if len (line) != 2:
self.command.not_understood (string.join (line)) self.command.not_understood (' '.join(line))
return return
response=make_response(self, self.size_completion) response=make_response(self, self.size_completion)
request=FTPRequest(line[1],'SIZE',self,response) request=FTPRequest(line[1],'SIZE',self,response)
...@@ -364,7 +363,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -364,7 +363,7 @@ class zope_ftp_channel(ftp_channel):
def cmd_retr(self,line): def cmd_retr(self,line):
if len(line) < 2: if len(line) < 2:
self.command_not_understood (string.join (line)) self.command_not_understood (' '.join(line))
return return
response=make_response(self, self.retr_completion, line[1]) response=make_response(self, self.retr_completion, line[1])
self._response_producers = response.stdout._producers self._response_producers = response.stdout._producers
...@@ -398,7 +397,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -398,7 +397,7 @@ class zope_ftp_channel(ftp_channel):
def cmd_stor (self, line, mode='wb'): def cmd_stor (self, line, mode='wb'):
'store a file' 'store a file'
if len (line) < 2: if len (line) < 2:
self.command_not_understood (string.join (line)) self.command_not_understood (' '.join(line))
return return
elif self.restart_position: elif self.restart_position:
restart_position = 0 restart_position = 0
...@@ -442,14 +441,14 @@ class zope_ftp_channel(ftp_channel): ...@@ -442,14 +441,14 @@ class zope_ftp_channel(ftp_channel):
def cmd_rnfr (self, line): def cmd_rnfr (self, line):
'rename from' 'rename from'
if len (line) != 2: if len (line) != 2:
self.command_not_understood (string.join (line)) self.command_not_understood (' '.join(line))
else: else:
self.fromfile = line[1] self.fromfile = line[1]
self.respond ('350 RNFR command successful.') self.respond ('350 RNFR command successful.')
def cmd_rnto (self, line): def cmd_rnto (self, line):
if len (line) != 2: if len (line) != 2:
self.command_not_understood (string.join (line)) self.command_not_understood (' '.join(line))
return return
pathf,idf=os.path.split(self.fromfile) pathf,idf=os.path.split(self.fromfile)
patht,idt=os.path.split(line[1]) patht,idt=os.path.split(line[1])
...@@ -466,7 +465,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -466,7 +465,7 @@ class zope_ftp_channel(ftp_channel):
def cmd_dele(self, line): def cmd_dele(self, line):
if len (line) != 2: if len (line) != 2:
self.command.not_understood (string.join (line)) self.command.not_understood (' '.join (line))
return return
path,id=os.path.split(line[1]) path,id=os.path.split(line[1])
response=make_response(self, self.dele_completion) response=make_response(self, self.dele_completion)
...@@ -475,7 +474,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -475,7 +474,7 @@ class zope_ftp_channel(ftp_channel):
def dele_completion(self,response): def dele_completion(self,response):
status=response.getStatus() status=response.getStatus()
if status==200 and string.find(response.body,'Not Deletable')==-1: if status==200 and response.body.find('Not Deletable')==-1:
self.respond('250 DELE command successful.') self.respond('250 DELE command successful.')
elif status==401: elif status==401:
self.respond('530 Unauthorized.') self.respond('530 Unauthorized.')
...@@ -484,7 +483,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -484,7 +483,7 @@ class zope_ftp_channel(ftp_channel):
def cmd_mkd(self, line): def cmd_mkd(self, line):
if len (line) != 2: if len (line) != 2:
self.command.not_understood (string.join (line)) self.command.not_understood (' '.join (line))
return return
path,id=os.path.split(line[1]) path,id=os.path.split(line[1])
response=make_response(self, self.mkd_completion) response=make_response(self, self.mkd_completion)
...@@ -506,7 +505,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -506,7 +505,7 @@ class zope_ftp_channel(ftp_channel):
# XXX should object be checked to see if it's folderish # XXX should object be checked to see if it's folderish
# before we allow it to be RMD'd? # before we allow it to be RMD'd?
if len (line) != 2: if len (line) != 2:
self.command.not_understood (string.join (line)) self.command.not_understood (' '.join (line))
return return
path,id=os.path.split(line[1]) path,id=os.path.split(line[1])
response=make_response(self, self.rmd_completion) response=make_response(self, self.rmd_completion)
...@@ -517,7 +516,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -517,7 +516,7 @@ class zope_ftp_channel(ftp_channel):
def rmd_completion(self,response): def rmd_completion(self,response):
status=response.getStatus() status=response.getStatus()
if status==200 and string.find(response.body,'Not Deletable')==-1: if status==200 and response.body.find('Not Deletable')==-1:
self.respond('250 RMD command successful.') self.respond('250 RMD command successful.')
elif status==401: elif status==401:
self.respond('530 Unauthorized.') self.respond('530 Unauthorized.')
...@@ -530,7 +529,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -530,7 +529,7 @@ class zope_ftp_channel(ftp_channel):
self.userid = line[1] self.userid = line[1]
self.respond('331 Password required.') self.respond('331 Password required.')
else: else:
self.command_not_understood (string.join (line)) self.command_not_understood (' '.join (line))
def cmd_pass(self, line): def cmd_pass(self, line):
'specify password' 'specify password'
...@@ -539,7 +538,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -539,7 +538,7 @@ class zope_ftp_channel(ftp_channel):
else: else:
pw = line[1] pw = line[1]
self.password=pw self.password=pw
i=string.find(self.userid,'@') i=self.userid.find('@')
if i ==-1: if i ==-1:
if self.server.limiter.check_limit(self): if self.server.limiter.check_limit(self):
self.respond ('230 Login successful.') self.respond ('230 Login successful.')
......
...@@ -89,7 +89,7 @@ The HTTPResponse class takes care of server headers, response munging ...@@ -89,7 +89,7 @@ The HTTPResponse class takes care of server headers, response munging
and logging duties. and logging duties.
""" """
import time, re, string, sys, tempfile import time, re, sys, tempfile
from cStringIO import StringIO from cStringIO import StringIO
import thread import thread
from ZPublisher.HTTPResponse import HTTPResponse from ZPublisher.HTTPResponse import HTTPResponse
...@@ -186,20 +186,20 @@ class ZServerHTTPResponse(HTTPResponse): ...@@ -186,20 +186,20 @@ class ZServerHTTPResponse(HTTPResponse):
self.setHeader('Connection','close') self.setHeader('Connection','close')
for key, val in headers.items(): for key, val in headers.items():
if string.lower(key)==key: if key.lower()==key:
# only change non-literal header names # only change non-literal header names
key="%s%s" % (string.upper(key[:1]), key[1:]) key="%s%s" % (key[:1].upper(), key[1:])
start=0 start=0
l=string.find(key,'-',start) l=key.find('-',start)
while l >= start: while l >= start:
key="%s-%s%s" % (key[:l],string.upper(key[l+1:l+2]),key[l+2:]) key="%s-%s%s" % (key[:l],key[l+1:l+2].upper(),key[l+2:])
start=l+1 start=l+1
l=string.find(key,'-',start) l=key.find('-',start)
append("%s: %s" % (key, val)) append("%s: %s" % (key, val))
if self.cookies: if self.cookies:
headersl=headersl+self._cookie_list() headersl=headersl+self._cookie_list()
headersl[len(headersl):]=[self.accumulated_headers, body] headersl[len(headersl):]=[self.accumulated_headers, body]
return string.join(headersl,'\r\n') return "\r\n".join(headersl)
_tempfile=None _tempfile=None
_templock=None _templock=None
...@@ -226,7 +226,7 @@ class ZServerHTTPResponse(HTTPResponse): ...@@ -226,7 +226,7 @@ class ZServerHTTPResponse(HTTPResponse):
l=self.headers.get('content-length', None) l=self.headers.get('content-length', None)
if l is not None: if l is not None:
try: try:
if type(l) is type(''): l=string.atoi(l) if type(l) is type(''): l=int(l)
if l > 128000: if l > 128000:
self._tempfile=tempfile.TemporaryFile() self._tempfile=tempfile.TemporaryFile()
self._templock=thread.allocate_lock() self._templock=thread.allocate_lock()
...@@ -356,7 +356,7 @@ class ChannelPipe: ...@@ -356,7 +356,7 @@ class ChannelPipe:
'exceptions.SystemExit': 'exceptions.SystemExit':
r=response.headers.get('bobo-exception-value','0') r=response.headers.get('bobo-exception-value','0')
try: r=string.atoi(r) try: r=int(r)
except: r = r and 1 or 0 except: r = r and 1 or 0
self._shutdown=r, self._shutdown=r,
if response.headers.get('connection','') == 'close' or \ if response.headers.get('connection','') == 'close' or \
...@@ -371,8 +371,8 @@ def make_response(request, headers): ...@@ -371,8 +371,8 @@ def make_response(request, headers):
response=ZServerHTTPResponse(stdout=ChannelPipe(request), stderr=StringIO()) response=ZServerHTTPResponse(stdout=ChannelPipe(request), stderr=StringIO())
response._http_version=request.version response._http_version=request.version
response._http_connection=string.lower( response._http_connection=(
http_server.get_header(http_server.CONNECTION, request.header)) http_server.get_header(http_server.CONNECTION, request.header)).lower()
response._server_version=request.channel.server.SERVER_IDENT response._server_version=request.channel.server.SERVER_IDENT
return response return response
......
...@@ -105,7 +105,6 @@ changes from Medusa's http_server ...@@ -105,7 +105,6 @@ changes from Medusa's http_server
""" """
import sys import sys
import re import re
import string
import os import os
import types import types
import thread import thread
......
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
__version__ = "1.0" __version__ = "1.0"
from HTTPServer import zhttp_handler from HTTPServer import zhttp_handler
import string, os import os
class WebDAVSrcHandler( zhttp_handler ): class WebDAVSrcHandler( zhttp_handler ):
""" """
...@@ -112,7 +112,7 @@ class WebDAVSrcHandler( zhttp_handler ): ...@@ -112,7 +112,7 @@ class WebDAVSrcHandler( zhttp_handler ):
path_info = os.path.join( path_info, 'manage_FTPget' ) path_info = os.path.join( path_info, 'manage_FTPget' )
path_info = os.path.normpath( path_info ) path_info = os.path.normpath( path_info )
if os.sep != '/': if os.sep != '/':
path_info = string.replace( path_info, os.sep, '/' ) path_info = path_info.replace( os.sep, '/' )
env['PATH_INFO'] = path_info env['PATH_INFO'] = path_info
...@@ -121,7 +121,7 @@ class WebDAVSrcHandler( zhttp_handler ): ...@@ -121,7 +121,7 @@ class WebDAVSrcHandler( zhttp_handler ):
# We check the user-agent and remove a trailing dot for PATH_INFO # We check the user-agent and remove a trailing dot for PATH_INFO
# and PATH_TRANSLATED # and PATH_TRANSLATED
if string.find(env.get("HTTP_USER_AGENT",""),"Microsoft Data Access Internet Publishing Provider")>-1: if env.get("HTTP_USER_AGENT","").find("Microsoft Data Access Internet Publishing Provider")>-1:
if env["PATH_INFO"][-1]=='.': if env["PATH_INFO"][-1]=='.':
env["PATH_INFO"] = env["PATH_INFO"][:-1] env["PATH_INFO"] = env["PATH_INFO"][:-1]
......
...@@ -183,7 +183,7 @@ TODO: ...@@ -183,7 +183,7 @@ TODO:
This script does for NT the same sort of thing zdaemon.py does for UNIX. This script does for NT the same sort of thing zdaemon.py does for UNIX.
Requires Python win32api extensions. Requires Python win32api extensions.
""" """
import sys, os, string, time, imp import sys, os, time, imp
# Some fancy path footwork is required here because we # Some fancy path footwork is required here because we
# may be run from python.exe or lib/win32/PythonService.exe # may be run from python.exe or lib/win32/PythonService.exe
...@@ -236,7 +236,7 @@ class ZServerService(win32serviceutil.ServiceFramework): ...@@ -236,7 +236,7 @@ class ZServerService(win32serviceutil.ServiceFramework):
path=os.path.join(home, 'ZServer', 'svcname.txt') path=os.path.join(home, 'ZServer', 'svcname.txt')
file=open(path, 'r') file=open(path, 'r')
_svc_name_=string.strip(file.readline()) _svc_name_=file.readline().strip()
file.close() file.close()
_svc_display_name_ = "Zope (%s)" % _svc_name_ _svc_display_name_ = "Zope (%s)" % _svc_name_
......
...@@ -94,7 +94,7 @@ from ZPublisher.HTTPRequest import HTTPRequest ...@@ -94,7 +94,7 @@ from ZPublisher.HTTPRequest import HTTPRequest
from cStringIO import StringIO from cStringIO import StringIO
import os import os
from base64 import encodestring from base64 import encodestring
import string,re import re
class FTPRequest(HTTPRequest): class FTPRequest(HTTPRequest):
...@@ -192,7 +192,7 @@ class FTPRequest(HTTPRequest): ...@@ -192,7 +192,7 @@ class FTPRequest(HTTPRequest):
path=apply(os.path.join,args) path=apply(os.path.join,args)
path=os.path.normpath(path) path=os.path.normpath(path)
if os.sep != '/': if os.sep != '/':
path=string.replace(path,os.sep,'/') path=path.replace(os.sep,'/')
return path return path
......
...@@ -147,7 +147,6 @@ from FTPRequest import FTPRequest ...@@ -147,7 +147,6 @@ from FTPRequest import FTPRequest
from ZServer import CONNECTION_LIMIT, requestCloseOnExec from ZServer import CONNECTION_LIMIT, requestCloseOnExec
from cStringIO import StringIO from cStringIO import StringIO
import string
import os import os
from mimetypes import guess_type from mimetypes import guess_type
import marshal import marshal
...@@ -174,7 +173,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -174,7 +173,7 @@ class zope_ftp_channel(ftp_channel):
path=apply(os.path.join,args) path=apply(os.path.join,args)
path=os.path.normpath(path) path=os.path.normpath(path)
if os.sep != '/': if os.sep != '/':
path=string.replace(path,os.sep,'/') path=path.replace(os.sep,'/')
return path return path
# Overriden async_chat methods # Overriden async_chat methods
...@@ -210,7 +209,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -210,7 +209,7 @@ class zope_ftp_channel(ftp_channel):
# XXX clean this up, maybe with getopts # XXX clean this up, maybe with getopts
if len(line) > 1: if len(line) > 1:
args = string.split(line[1]) args = line[1].split()
else: else:
args =[] args =[]
path_args = [] path_args = []
...@@ -220,7 +219,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -220,7 +219,7 @@ class zope_ftp_channel(ftp_channel):
for i in range(len(args)): for i in range(len(args)):
x = args[i] x = args[i]
if string.find(x,'*')!=-1 or string.find(x,'?')!=-1: if x.find('*')!=-1 or x.find('?')!=-1:
self.globbing = x self.globbing = x
args[i] = '.' args[i] = '.'
...@@ -318,7 +317,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -318,7 +317,7 @@ class zope_ftp_channel(ftp_channel):
def cmd_mdtm(self, line): def cmd_mdtm(self, line):
'show last modification time of file' 'show last modification time of file'
if len (line) != 2: if len (line) != 2:
self.command.not_understood (string.join (line)) self.command.not_understood (' '.join(line))
return return
response=make_response(self, self.mdtm_completion) response=make_response(self, self.mdtm_completion)
request=FTPRequest(line[1],'MDTM',self,response) request=FTPRequest(line[1],'MDTM',self,response)
...@@ -345,7 +344,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -345,7 +344,7 @@ class zope_ftp_channel(ftp_channel):
def cmd_size(self, line): def cmd_size(self, line):
'return size of file' 'return size of file'
if len (line) != 2: if len (line) != 2:
self.command.not_understood (string.join (line)) self.command.not_understood (' '.join(line))
return return
response=make_response(self, self.size_completion) response=make_response(self, self.size_completion)
request=FTPRequest(line[1],'SIZE',self,response) request=FTPRequest(line[1],'SIZE',self,response)
...@@ -364,7 +363,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -364,7 +363,7 @@ class zope_ftp_channel(ftp_channel):
def cmd_retr(self,line): def cmd_retr(self,line):
if len(line) < 2: if len(line) < 2:
self.command_not_understood (string.join (line)) self.command_not_understood (' '.join(line))
return return
response=make_response(self, self.retr_completion, line[1]) response=make_response(self, self.retr_completion, line[1])
self._response_producers = response.stdout._producers self._response_producers = response.stdout._producers
...@@ -398,7 +397,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -398,7 +397,7 @@ class zope_ftp_channel(ftp_channel):
def cmd_stor (self, line, mode='wb'): def cmd_stor (self, line, mode='wb'):
'store a file' 'store a file'
if len (line) < 2: if len (line) < 2:
self.command_not_understood (string.join (line)) self.command_not_understood (' '.join(line))
return return
elif self.restart_position: elif self.restart_position:
restart_position = 0 restart_position = 0
...@@ -442,14 +441,14 @@ class zope_ftp_channel(ftp_channel): ...@@ -442,14 +441,14 @@ class zope_ftp_channel(ftp_channel):
def cmd_rnfr (self, line): def cmd_rnfr (self, line):
'rename from' 'rename from'
if len (line) != 2: if len (line) != 2:
self.command_not_understood (string.join (line)) self.command_not_understood (' '.join(line))
else: else:
self.fromfile = line[1] self.fromfile = line[1]
self.respond ('350 RNFR command successful.') self.respond ('350 RNFR command successful.')
def cmd_rnto (self, line): def cmd_rnto (self, line):
if len (line) != 2: if len (line) != 2:
self.command_not_understood (string.join (line)) self.command_not_understood (' '.join(line))
return return
pathf,idf=os.path.split(self.fromfile) pathf,idf=os.path.split(self.fromfile)
patht,idt=os.path.split(line[1]) patht,idt=os.path.split(line[1])
...@@ -466,7 +465,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -466,7 +465,7 @@ class zope_ftp_channel(ftp_channel):
def cmd_dele(self, line): def cmd_dele(self, line):
if len (line) != 2: if len (line) != 2:
self.command.not_understood (string.join (line)) self.command.not_understood (' '.join (line))
return return
path,id=os.path.split(line[1]) path,id=os.path.split(line[1])
response=make_response(self, self.dele_completion) response=make_response(self, self.dele_completion)
...@@ -475,7 +474,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -475,7 +474,7 @@ class zope_ftp_channel(ftp_channel):
def dele_completion(self,response): def dele_completion(self,response):
status=response.getStatus() status=response.getStatus()
if status==200 and string.find(response.body,'Not Deletable')==-1: if status==200 and response.body.find('Not Deletable')==-1:
self.respond('250 DELE command successful.') self.respond('250 DELE command successful.')
elif status==401: elif status==401:
self.respond('530 Unauthorized.') self.respond('530 Unauthorized.')
...@@ -484,7 +483,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -484,7 +483,7 @@ class zope_ftp_channel(ftp_channel):
def cmd_mkd(self, line): def cmd_mkd(self, line):
if len (line) != 2: if len (line) != 2:
self.command.not_understood (string.join (line)) self.command.not_understood (' '.join (line))
return return
path,id=os.path.split(line[1]) path,id=os.path.split(line[1])
response=make_response(self, self.mkd_completion) response=make_response(self, self.mkd_completion)
...@@ -506,7 +505,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -506,7 +505,7 @@ class zope_ftp_channel(ftp_channel):
# XXX should object be checked to see if it's folderish # XXX should object be checked to see if it's folderish
# before we allow it to be RMD'd? # before we allow it to be RMD'd?
if len (line) != 2: if len (line) != 2:
self.command.not_understood (string.join (line)) self.command.not_understood (' '.join (line))
return return
path,id=os.path.split(line[1]) path,id=os.path.split(line[1])
response=make_response(self, self.rmd_completion) response=make_response(self, self.rmd_completion)
...@@ -517,7 +516,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -517,7 +516,7 @@ class zope_ftp_channel(ftp_channel):
def rmd_completion(self,response): def rmd_completion(self,response):
status=response.getStatus() status=response.getStatus()
if status==200 and string.find(response.body,'Not Deletable')==-1: if status==200 and response.body.find('Not Deletable')==-1:
self.respond('250 RMD command successful.') self.respond('250 RMD command successful.')
elif status==401: elif status==401:
self.respond('530 Unauthorized.') self.respond('530 Unauthorized.')
...@@ -530,7 +529,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -530,7 +529,7 @@ class zope_ftp_channel(ftp_channel):
self.userid = line[1] self.userid = line[1]
self.respond('331 Password required.') self.respond('331 Password required.')
else: else:
self.command_not_understood (string.join (line)) self.command_not_understood (' '.join (line))
def cmd_pass(self, line): def cmd_pass(self, line):
'specify password' 'specify password'
...@@ -539,7 +538,7 @@ class zope_ftp_channel(ftp_channel): ...@@ -539,7 +538,7 @@ class zope_ftp_channel(ftp_channel):
else: else:
pw = line[1] pw = line[1]
self.password=pw self.password=pw
i=string.find(self.userid,'@') i=self.userid.find('@')
if i ==-1: if i ==-1:
if self.server.limiter.check_limit(self): if self.server.limiter.check_limit(self):
self.respond ('230 Login successful.') self.respond ('230 Login successful.')
......
...@@ -89,7 +89,7 @@ The HTTPResponse class takes care of server headers, response munging ...@@ -89,7 +89,7 @@ The HTTPResponse class takes care of server headers, response munging
and logging duties. and logging duties.
""" """
import time, re, string, sys, tempfile import time, re, sys, tempfile
from cStringIO import StringIO from cStringIO import StringIO
import thread import thread
from ZPublisher.HTTPResponse import HTTPResponse from ZPublisher.HTTPResponse import HTTPResponse
...@@ -186,20 +186,20 @@ class ZServerHTTPResponse(HTTPResponse): ...@@ -186,20 +186,20 @@ class ZServerHTTPResponse(HTTPResponse):
self.setHeader('Connection','close') self.setHeader('Connection','close')
for key, val in headers.items(): for key, val in headers.items():
if string.lower(key)==key: if key.lower()==key:
# only change non-literal header names # only change non-literal header names
key="%s%s" % (string.upper(key[:1]), key[1:]) key="%s%s" % (key[:1].upper(), key[1:])
start=0 start=0
l=string.find(key,'-',start) l=key.find('-',start)
while l >= start: while l >= start:
key="%s-%s%s" % (key[:l],string.upper(key[l+1:l+2]),key[l+2:]) key="%s-%s%s" % (key[:l],key[l+1:l+2].upper(),key[l+2:])
start=l+1 start=l+1
l=string.find(key,'-',start) l=key.find('-',start)
append("%s: %s" % (key, val)) append("%s: %s" % (key, val))
if self.cookies: if self.cookies:
headersl=headersl+self._cookie_list() headersl=headersl+self._cookie_list()
headersl[len(headersl):]=[self.accumulated_headers, body] headersl[len(headersl):]=[self.accumulated_headers, body]
return string.join(headersl,'\r\n') return "\r\n".join(headersl)
_tempfile=None _tempfile=None
_templock=None _templock=None
...@@ -226,7 +226,7 @@ class ZServerHTTPResponse(HTTPResponse): ...@@ -226,7 +226,7 @@ class ZServerHTTPResponse(HTTPResponse):
l=self.headers.get('content-length', None) l=self.headers.get('content-length', None)
if l is not None: if l is not None:
try: try:
if type(l) is type(''): l=string.atoi(l) if type(l) is type(''): l=int(l)
if l > 128000: if l > 128000:
self._tempfile=tempfile.TemporaryFile() self._tempfile=tempfile.TemporaryFile()
self._templock=thread.allocate_lock() self._templock=thread.allocate_lock()
...@@ -356,7 +356,7 @@ class ChannelPipe: ...@@ -356,7 +356,7 @@ class ChannelPipe:
'exceptions.SystemExit': 'exceptions.SystemExit':
r=response.headers.get('bobo-exception-value','0') r=response.headers.get('bobo-exception-value','0')
try: r=string.atoi(r) try: r=int(r)
except: r = r and 1 or 0 except: r = r and 1 or 0
self._shutdown=r, self._shutdown=r,
if response.headers.get('connection','') == 'close' or \ if response.headers.get('connection','') == 'close' or \
...@@ -371,8 +371,8 @@ def make_response(request, headers): ...@@ -371,8 +371,8 @@ def make_response(request, headers):
response=ZServerHTTPResponse(stdout=ChannelPipe(request), stderr=StringIO()) response=ZServerHTTPResponse(stdout=ChannelPipe(request), stderr=StringIO())
response._http_version=request.version response._http_version=request.version
response._http_connection=string.lower( response._http_connection=(
http_server.get_header(http_server.CONNECTION, request.header)) http_server.get_header(http_server.CONNECTION, request.header)).lower()
response._server_version=request.channel.server.SERVER_IDENT response._server_version=request.channel.server.SERVER_IDENT
return response return response
......
...@@ -105,7 +105,6 @@ changes from Medusa's http_server ...@@ -105,7 +105,6 @@ changes from Medusa's http_server
""" """
import sys import sys
import re import re
import string
import os import os
import types import types
import thread import thread
......
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
__version__ = "1.0" __version__ = "1.0"
from HTTPServer import zhttp_handler from HTTPServer import zhttp_handler
import string, os import os
class WebDAVSrcHandler( zhttp_handler ): class WebDAVSrcHandler( zhttp_handler ):
""" """
...@@ -112,7 +112,7 @@ class WebDAVSrcHandler( zhttp_handler ): ...@@ -112,7 +112,7 @@ class WebDAVSrcHandler( zhttp_handler ):
path_info = os.path.join( path_info, 'manage_FTPget' ) path_info = os.path.join( path_info, 'manage_FTPget' )
path_info = os.path.normpath( path_info ) path_info = os.path.normpath( path_info )
if os.sep != '/': if os.sep != '/':
path_info = string.replace( path_info, os.sep, '/' ) path_info = path_info.replace( os.sep, '/' )
env['PATH_INFO'] = path_info env['PATH_INFO'] = path_info
...@@ -121,7 +121,7 @@ class WebDAVSrcHandler( zhttp_handler ): ...@@ -121,7 +121,7 @@ class WebDAVSrcHandler( zhttp_handler ):
# We check the user-agent and remove a trailing dot for PATH_INFO # We check the user-agent and remove a trailing dot for PATH_INFO
# and PATH_TRANSLATED # and PATH_TRANSLATED
if string.find(env.get("HTTP_USER_AGENT",""),"Microsoft Data Access Internet Publishing Provider")>-1: if env.get("HTTP_USER_AGENT","").find("Microsoft Data Access Internet Publishing Provider")>-1:
if env["PATH_INFO"][-1]=='.': if env["PATH_INFO"][-1]=='.':
env["PATH_INFO"] = env["PATH_INFO"][:-1] env["PATH_INFO"] = env["PATH_INFO"][:-1]
......
...@@ -183,7 +183,7 @@ TODO: ...@@ -183,7 +183,7 @@ TODO:
This script does for NT the same sort of thing zdaemon.py does for UNIX. This script does for NT the same sort of thing zdaemon.py does for UNIX.
Requires Python win32api extensions. Requires Python win32api extensions.
""" """
import sys, os, string, time, imp import sys, os, time, imp
# Some fancy path footwork is required here because we # Some fancy path footwork is required here because we
# may be run from python.exe or lib/win32/PythonService.exe # may be run from python.exe or lib/win32/PythonService.exe
...@@ -236,7 +236,7 @@ class ZServerService(win32serviceutil.ServiceFramework): ...@@ -236,7 +236,7 @@ class ZServerService(win32serviceutil.ServiceFramework):
path=os.path.join(home, 'ZServer', 'svcname.txt') path=os.path.join(home, 'ZServer', 'svcname.txt')
file=open(path, 'r') file=open(path, 'r')
_svc_name_=string.strip(file.readline()) _svc_name_=file.readline().strip()
file.close() file.close()
_svc_display_name_ = "Zope (%s)" % _svc_name_ _svc_display_name_ = "Zope (%s)" % _svc_name_
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment