Frederick Grim
fred at forsalebyowner.com
Tue Mar 9 09:25:55 EST 2004
Erik Stephens at <mod_python at 24ksoftware.com> replied: > On Mon, 8 Mar 2004, Frederick Grim wrote: > > > def gen_xml(): > > return """<?xml ... Tons of xhtml stuff here > > > > </html>""" > > > > def main(req, ERR='0'): > > re.content_type = 'text/xml' > > req.write(gen_xml()) > > return apache.OK > > > > The problem here is that python puts null bytes at the end of a > > string and req.write fails with the error that there is a 0 after > > </html>. > > How does it fail? Raises an exception? What is the actual exception > type and value? It sounds strange to me cuz I've never had to worry > about null bytes in strings in my Python travels. okay I have tracked the problem down. It seems that return apache.OK adds a 0 to the output that the browser picks up so somewhere between function and browser mod_python leaves the zero at the end of the string. The problem manifested itself with a failure when content_type was set to 'text/xml' since I guess mod_python shoved the output through a validating parser. 1. Is this a correct analysis 2. Is this a bug or my misuse of mod_python if is_bug: print 'Has this been addressed?' else: fred_file_bug_report() heh :) Fred > > > > How do I get this failure to not happen. Even if i set content_type > > to 'text/html' there appears a little zero at the end of my > > script. It seems like a bug? maybe. I am using mod_python 3.1.3 > > apache 2.0.47, and python 2.3 > > Dumb questions maybe, but what handler are you using? If you're using > the publisher handler, then maybe that zero at the end is what > apache.OK equals? > > > Best regards, > Erik > > _______________________________________________ > Mod_python mailing list > Mod_python at modpython.org > http://mailman.modpython.org/mailman/listinfo/mod_python -- "Windows Longhorn will be like having a little cop right inside your computer" -- Jorge Lopez, MCSE
|