[Zope-dev] XML-RPC does not work under the paster process

Michael Haubenwallner michael at d2m.at
Mon May 25 11:08:41 EDT 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Christian Theune wrote:
> On Wed, 2009-03-18 at 13:12 +0100, Michael Haubenwallner wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Michael Haubenwallner wrote:
>>> When using paste.httpserver instead of twisted.wsgi server
>>> zope.publisher.xmlrpc.XMLRPCRequest.processInputs() hangs when reading 0
>>> Bytes from the request (wsgi.input <socket._fileobject object>).
>>>
>>> As i found the zope.publisher.http.HTTPInputStream.readlines() signature
>>> was changed 3 years ago
>>> from readlines(self, hint=None)
>>> to   readlines(self, hint=0)
>>> http://svn.zope.org/Zope3/trunk/src/zope/publisher/http.py?rev=66941&r1=66940&r2=66941
>>>
>>> Do you think we could revert the change?
>>>
>>> Bugs reported:
>>> zopeproject: https://bugs.launchpad.net/zope3/+bug/283089
>>> grokproject: https://bugs.launchpad.net/grok/+bug/332063
>>>
>> Bump - maybe my description was too complicated, but the issue is serious:
>>
>>   XMLRPC is broken at least with paste.httpserver
>>
>> Any input on the implications of reverting the change in revision #66941?
> 
> I've looked at the various APIs of actual objects that need to consume
> the size hint parameter (cStringIO, StringIO, file, socket._fileobject).
> 
> All of them should be fine getting a 0 as an argument, but file and
> cStringIO will break if they get `None` instead of 0:
> 
> Type                    | readlines() | readlines(None) | readlines(0)
> ------------------------+-------------+-----------------+--------------
> file                    | works       | TypeError       | works
> StringIO                | works       | works           | works
> cStringIO               | works       | TypeError       | works
> socket._fileobject [1]_ | works       | works           | works
> 
> .. [1]  I've only looked at the code and reasoned about this.
> 
> What I'm puzzled about is that the commit message of 66491 mentions
> compatibility to StringIO but that would have worked just fine with
> `None`. So this either actually means "compatibility with file" or
> "compatibility with cStringIO".
> 
> Nevertheless: passing in 0 seems to be the safe bet in general and I
> wonder what is actually breaking. I haven't seen a traceback be attached
> at either bug. Also, those bugs should probably be marked as duplicates.
> 

You are right, looking at the problem again i suggest to add this change
to zope.publisher.xmlrpc

- --- src/zope/publisher/xmlrpc.py	(revision 100356)
+++ src/zope/publisher/xmlrpc.py	(working copy)
@@ -46,10 +46,14 @@
         'See IPublisherRequest'
         # Parse the request XML structure

- -        # XXX using readlines() instead of lines()
- -        # as twisted's BufferedStream sends back
- -        # an empty stream here for read() (bug)
- -        lines = ''.join(self._body_instream.readlines())
+        # XXX using readline() instead of readlines()
+        # as readlines() is not working with
+        # paster.httpserver
+        line = 1
+        lines = ''
+        while line != '':
+            line = self._body_instream.readline()
+            lines += line
         self._args, function = xmlrpclib.loads(lines)


The fix was proposed by jens Klein, see
https://bugs.launchpad.net/zope3/+bug/283089/comments/3

If noone objects i will add it to the zope.publisher 3.4 branch
and make a release (3.4.8). The fix is needed at least for Grok to make
XMLRPC work with paster.httpserver.

Regards
Michael

- --
http://blog.d2m.at
http://planetzope.org

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFKGrR4l0uAvQJUKVYRAh1hAKCJDDSM/MDeuuzOn9jddnZWsfI2IACgnWOi
lMnwK3vbJcAYu5miFKXjAH8=
=Fxqf
-----END PGP SIGNATURE-----



More information about the Zope-Dev mailing list