Re: Getting xml-rpc and w.bloggar to work
will <[email protected]>
| Newsgroups | gmane.comp.web.pyblosxom.user |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 13 Aug 2003, Abe Fettig wrote: > > I haven't even looked at the code in question, but I agree that it's > always good to understand why a fix works. So I'd like to suggest a > possible explanation. It seems that "-u" not only turns off buffered > output, but tells Python to treat stdin and stdout as binary. This, in > turn, has the effect of disabling "\n"->"\r\n" translation, which I > believe is the default on Windows, which could indeed cause you problems > if you're explicitly passing the Content-length header, since it would > add an additional byte per line. Intriguing. That would make a lot of sense. Though I think Wari's also saying that a bunch of tags are disappearing from the output stream. Wari sent me an email about setting up xmlrpc and the environment he's got. I don't really have time to do it for a while--I'm moving this weekend and all my time is going towards packing and such. As I understand it, there are two issues: 1. not all the data gets to the client 2. the xml tags are getting corrupted I would think that changing the print -> sys.stdout.write and fixing the Content-Length (the one in CVS is off by one right now) and then adding a sys.stdout.flush() is a possible solution for issue 1. I have no clue what issue 2 could be and don't see how it's related to using python -u except in the case that since the XML document isn't finished, the xml parser in the client gets all befuddled. I'm totally guessing on that though. I tossed this into a patch. Wari--can you see if the attached patch works at all? /will
xmlrpc.py.diff
(text/plain, 957 B)
Index: xmlrpc.py
===================================================================
RCS file: /cvsroot/pyblosxom/pyblosxom/Pyblosxom/xmlrpc.py,v
retrieving revision 1.4
diff -u -r1.4 xmlrpc.py
--- xmlrpc.py 29 Jul 2003 02:54:45 -0000 1.4
+++ xmlrpc.py 13 Aug 2003 17:43:46 -0000
@@ -53,9 +53,10 @@
response = xmlrpclib.dumps(response, methodresponse=1)
except:
- print 'Content-type: text/plain\n\nXML-RPC call expected\nDebug: %s:%s' % (sys.exc_type, sys.exc_value)
+ sys.stdout.write('Content-type: text/plain\n\nXML-RPC call expected\nDebug: %s:%s' % (sys.exc_type, sys.exc_value))
else:
- print 'Content-type: text/xml\nContent-length: %d\n\n%s\n' % (len(response), response)
+ sys.stdout.write('Content-type: text/xml\nContent-length: %d\n\n%s' % (len(response), response))
+ sys.stdout.flush()
def xmlrpcCall(self, meth_name, args):