I am trying to use xml-rpc to get hold of some files uploaded to one Zope server, send them to another for some processing, and then have them returned to the first server. My difficulty is in the authentication part. I have read Amos' tutorial (http://www.zope.org/Members/Amos/XML-RPC), and understand that xmlrpclib.py in its standard form does not handle http authentication. My problem is that I'm not really that hot on python, so I don't totally understand how to implement Amos' BasicAuthTransport class. Where should I put this code? Do I need to make any more alterations (other than subclassing 'transport' as opposed to 'xmlrpclib.transport')? I had a go at getting things to work; here's what I did: 1) Made a copy of xmlrpclib.py named xmlrpclibx.py to play with 2) Pasted in Amos' BasicAuthTransport class code. 3) Changed the line in the 'Server' class so that it set 'transport' to 'BasicAuthTransport()' ... but I simply got a syntax error when I tried to 'import xmlrpclibx' in my external method. Can anyone help me out? thanks tim
Where should I put this code? Do I need to make any more alterations (other than subclassing 'transport' as opposed to 'xmlrpclib.transport')?
Nope. ZSyncer, uses a script based on Amos's original code very successfully btw. I use it a great deal. If you look at that python it might help basically just put xmlrpclibBasicAuth.py (from ZSyncer) in Zope/bin/lib. And instead of calling xmlrpclib, call xmlrpclibBasicAuth: from xmlrpclibBasicAuth import Server s = Server('http://foo.bar.com', 'user', pwd') s.hello() Cheers. -- Andy McKay.
----- Original Message ----- From: "Andy McKay" <andym@ActiveState.com> To: "Tim Hicks" <tim@sitefusion.co.uk>; <zope@zope.org> Sent: Thursday, June 28, 2001 5:48 PM Subject: Re: [Zope] xml-rpc authentication
Where should I put this code? Do I need to make any more alterations (other than subclassing 'transport' as opposed to 'xmlrpclib.transport')?
Nope. ZSyncer, uses a script based on Amos's original code very successfully btw. I use it a great deal. If you look at that python it might help basically just put xmlrpclibBasicAuth.py (from ZSyncer) in Zope/bin/lib.
And instead of calling xmlrpclib, call xmlrpclibBasicAuth:
from xmlrpclibBasicAuth import Server s = Server('http://foo.bar.com', 'user', pwd') s.hello()
Andy, thats great. It works a treat :-))). I've now found another little problem. I can call any method on the remote Zope server that simply requires plain text arguments, but when I try to send binary over, I get, Error Type: AttributeError Error Value: seek This is whether I use xmlrpclib.binary(mybinarydata) or simply pass mybinarydata. I searched the zope list, and found that 'Kyler B. Laird' posted a message with this very problem (hence Kyler being cc'd - hope you don't mind Kyler), but there was no reply to it, so I couldn't find out how/if there was a resolution. Do you have any idea what I'm doing wrong? thanks tim ps Just like to say thanks David for your suggested solution. I went with Andy's simply because his mail arrived first. I appreciate your time. Your 'method' was actually very instructive for me in the ways of python :-).
You might try using base64 encoding and decoding. Cheers. -- Andy McKay. ----- Original Message ----- From: "Tim Hicks" <tim@sitefusion.co.uk> To: "Andy McKay" <andym@activestate.com>; <zope@zope.org>; "David Burton" <eloquence@eloquent-designs.f2s.com> Cc: <laird@ecn.purdue.edu> Sent: Thursday, June 28, 2001 6:41 PM Subject: xml-rpc.binary and 'seek' (was Re: [Zope] xml-rpc authentication)
----- Original Message ----- From: "Andy McKay" <andym@ActiveState.com> To: "Tim Hicks" <tim@sitefusion.co.uk>; <zope@zope.org> Sent: Thursday, June 28, 2001 5:48 PM Subject: Re: [Zope] xml-rpc authentication
Where should I put this code? Do I need to make any more alterations (other than subclassing 'transport' as opposed to 'xmlrpclib.transport')?
Nope. ZSyncer, uses a script based on Amos's original code very successfully btw. I use it a great deal. If you look at that python it might help basically just put xmlrpclibBasicAuth.py (from ZSyncer) in Zope/bin/lib.
And instead of calling xmlrpclib, call xmlrpclibBasicAuth:
from xmlrpclibBasicAuth import Server s = Server('http://foo.bar.com', 'user', pwd') s.hello()
Andy,
thats great. It works a treat :-))). I've now found another little problem. I can call any method on the remote Zope server that simply requires plain text arguments, but when I try to send binary over, I get,
Error Type: AttributeError Error Value: seek
This is whether I use xmlrpclib.binary(mybinarydata) or simply pass mybinarydata. I searched the zope list, and found that 'Kyler B. Laird' posted a message with this very problem (hence Kyler being cc'd - hope you don't mind Kyler), but there was no reply to it, so I couldn't find out how/if there was a resolution. Do you have any idea what I'm doing wrong?
thanks
tim
ps Just like to say thanks David for your suggested solution. I went with Andy's simply because his mail arrived first. I appreciate your time. Your 'method' was actually very instructive for me in the ways of python :-).
----- Original Message ----- From: "Andy McKay" <andym@ActiveState.com> To: "Tim Hicks" <tim@sitefusion.co.uk>; <zope@zope.org>; "David Burton" <eloquence@eloquent-designs.f2s.com> Cc: <laird@ecn.purdue.edu> Sent: Friday, June 29, 2001 9:00 PM Subject: Re: xml-rpc.binary and 'seek' (was Re: [Zope] xml-rpc authentication)
You might try using base64 encoding and decoding.
Andy, you've saved me again. Here's what I use from the 'client' end, -----start scriptlet---------- from Shared.UoB.xmlrpclibBasicAuth import Server import xmlrpclib, base64 def transfer2server(self, url, image, img_id,): s = Server(url, 'username', 'password') s.doimage(img_id, base64.encodestring(image)) -----end scriptlet---------- The 'doimage' method on the remote system simply has a base64.decodestring() and then does what it wants. In my case, manage_addImage(). Thanks very much. tim
Cheers. -- Andy McKay.
----- Original Message ----- From: "Tim Hicks" <tim@sitefusion.co.uk> To: "Andy McKay" <andym@activestate.com>; <zope@zope.org>; "David Burton" <eloquence@eloquent-designs.f2s.com> Cc: <laird@ecn.purdue.edu> Sent: Thursday, June 28, 2001 6:41 PM Subject: xml-rpc.binary and 'seek' (was Re: [Zope] xml-rpc authentication)
----- Original Message ----- From: "Andy McKay" <andym@ActiveState.com> To: "Tim Hicks" <tim@sitefusion.co.uk>; <zope@zope.org> Sent: Thursday, June 28, 2001 5:48 PM Subject: Re: [Zope] xml-rpc authentication
Where should I put this code? Do I need to make any more alterations (other than subclassing 'transport' as opposed to 'xmlrpclib.transport')?
Nope. ZSyncer, uses a script based on Amos's original code very successfully btw. I use it a great deal. If you look at that python it might help basically just put xmlrpclibBasicAuth.py (from ZSyncer) in Zope/bin/lib.
And instead of calling xmlrpclib, call xmlrpclibBasicAuth:
from xmlrpclibBasicAuth import Server s = Server('http://foo.bar.com', 'user', pwd') s.hello()
Andy,
thats great. It works a treat :-))). I've now found another little problem. I can call any method on the remote Zope server that simply requires plain text arguments, but when I try to send binary over, I get,
Error Type: AttributeError Error Value: seek
This is whether I use xmlrpclib.binary(mybinarydata) or simply pass mybinarydata. I searched the zope list, and found that 'Kyler B. Laird' posted a message with this very problem (hence Kyler being cc'd - hope you don't mind Kyler), but there was no reply to it, so I couldn't find out how/if there was a resolution. Do you have any idea what I'm doing wrong?
thanks
tim
ps Just like to say thanks David for your suggested solution. I went with Andy's simply because his mail arrived first. I appreciate your time. Your 'method' was actually very instructive for me in the ways of python :-).
participants (2)
-
Andy McKay -
Tim Hicks