# HG changeset patch # User Alexis S. L. Carvalho # Date 1174342059 10800 # Node ID cc81c512a5316a025f2ca8bb0c1113b5d28b83bb # Parent bd46b83b9692809e1cee1bf40f620a95764b86e4 avoid _wsgioutputfile <-> _wsgirequest circular reference We use the _wsgirequest object itself as the output file object. To avoid a "self.out = self" which would create another circular reference, we make the "out" attribute a trivial property. diff -r bd46b83b9692 -r cc81c512a531 mercurial/hgweb/request.py --- a/mercurial/hgweb/request.py Mon Mar 19 19:07:38 2007 -0300 +++ b/mercurial/hgweb/request.py Mon Mar 19 19:07:39 2007 -0300 @@ -17,20 +17,6 @@ def __call__(self, wsgienv, start_response): return _wsgirequest(self.destmaker(), wsgienv, start_response) -class _wsgioutputfile(object): - def __init__(self, request): - self.request = request - - def write(self, data): - self.request.write(data) - def writelines(self, lines): - for line in lines: - self.write(line) - def flush(self): - return None - def close(self): - return None - class _wsgirequest(object): def __init__(self, destination, wsgienv, start_response): version = wsgienv['wsgi.version'] @@ -38,7 +24,6 @@ raise RuntimeError("Unknown and unsupported WSGI version %d.%d" \ % version) self.inp = wsgienv['wsgi.input'] - self.out = _wsgioutputfile(self) self.server_write = None self.err = wsgienv['wsgi.errors'] self.threaded = wsgienv['wsgi.multithread'] @@ -50,6 +35,8 @@ self.headers = [] destination.run_wsgi(self) + out = property(lambda self: self) + def __iter__(self): return iter([]) @@ -76,6 +63,16 @@ if inst[0] != errno.ECONNRESET: raise + def writelines(self, lines): + for line in lines: + self.write(line) + + def flush(self): + return None + + def close(self): + return None + def header(self, headers=[('Content-type','text/html')]): self.headers.extend(headers)