[Zope] Content-length

Robert Roy rjroy@takingcontrol.com
Sat, 08 Apr 2000 12:12:15 -0400


I am using a sub-set of Zope 2.16 i.e. ZPublisher, DocumentTemplate with a standard CGI calling convention via Apache on NT(no PCGI or FastCGI at this point). I want to use the TreeTag with this so I have been playing around with it and have it partially working so far.

I am having an amusing? problem. The TreeTag outputs multiple lines separating them with '\n'. When the Publish module calculates the content length it sees one character per new line for example it evaluates 'this\nis\na\ntest\n' properly as being 15 chars in length. However when sys.stdout writes it, it converts '\n' to '\r\n' this being Windows and all. So my 15 character string has now been effectively lengthed to 19 characters and the displayed output is truncated by 4 characters.

I tried replacing '\n'  with os.linesep and this works for the tree code but has no effect on the rest of the stuff that gets generated.

I am sure I am not the first to run in to this, does anyone have a solution they wish to share? I know I can fix this with a regular expression substitution but I would like to avoid that if I can.

Bob