[Twisted-Python] Two fixes
Bertrand Croq
bertrand.croq at freeskop.com
Tue May 25 06:44:57 MDT 2004
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)
--
Bertrand Croq
FreesKop - Avenue Robert Schuman - 35170 BRUZ - France
http://www.freeskop.com/
More information about the Twisted-Python
mailing list