[Twisted-Python] Two fixes

Hi, I am currently using Twisted to write a web site, and I wanted the site to be able to download updates from its subversion repository. Doing this, I found a bug: HTTPFactory.log does not check for a logFile attribute before using it
Here is a patch that fixes the problem
Index: protocols/http.py =================================================================== --- protocols/http.py (revision 10776) +++ protocols/http.py (working copy) @@ -1120,13 +1120,14 @@
def log(self, request): """Log a request's result to the logfile, by default in combined log format.""" - line = '%s - - %s "%s" %d %s "%s" "%s"\n' % ( - request.getClientIP(), - # request.getUser() or "-", # the remote user is almost never important - _logDateTime, - '%s %s %s' % (request.method, request.uri, request.clientproto), - request.code, - request.sentLength or "-", - request.getHeader("referer") or "-", - request.getHeader("user-agent") or "-") - self.logFile.write(line) + if hasattr(self, "logFile"): + line = '%s - - %s "%s" %d %s "%s" "%s"\n' % ( + request.getClientIP(), + # request.getUser() or "-", # the remote user is almost never important + _logDateTime, + '%s %s %s' % (request.method, request.uri, request.clientproto), + request.code, + request.sentLength or "-", + request.getHeader("referer") or "-", + request.getHeader("user-agent") or "-") + self.logFile.write(line)

Please add this to http://twistedmatrix.com/bugs/ and assign to jknight.
participants (2)
-
Bertrand Croq
-
Itamar Shtull-Trauring