Help: XMLRPC question
Hello zope users, I have comp A Zope and comp B Zope on LAN. I've wrote python wrappers for vpopmail API (vadduser, vdeluser, vpasswd), compiled it into .so module, put it into comp A Zope ../zope/lib/python2.1/site-packages and restarted zope. Here are my external methods on comp A Zope: import vpopmail # my wrapper module for vpopmail def vadduser(username, domain, password): return vpopmail.vadduser(username, domain, password, "", 0) def vdeluser(username, domain): return vpopmail.vdeluser(username, domain) def vpasswd(username, domain, password): return vpopmail.vpasswd(username, domain, password, 0) It works OK, each method return 1 if OK and 0 if Error Problem begins when I begin to call these external methods from comp B Zope using XML-RPC. Comp B Zope external methods from xmlrpclib import Server def vadduser(username, domain, password): s = Server(http://server/vpopmail) return s.vadduser(username, domain, password) ..... So I can get results (0 or 1) from calling ext. methods from comp A The problem is that it works and sometimes doesn't work. Often I get error on comp B Zope: Traceback (innermost last): File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 150, in publish_module File /usr/local/zope/lib/python/Products/Localizer/__init__.py, line 65, in new_publish File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 114, in publish File /usr/local/zope/lib/python/Zope/__init__.py, line 159, in zpublisher_exception_hook (Object: vpopmail) File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 98, in publish File /usr/local/zope/lib/python/ZPublisher/mapply.py, line 88, in mapply (Object: vadduser) File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 39, in call_object (Object: vadduser) File /usr/local/zope/lib/python/Shared/DC/Scripts/Bindings.py, line 252, in __call__ (Object: vadduser) File /usr/local/zope/lib/python/Shared/DC/Scripts/Bindings.py, line 283, in _bindAndExec (Object: vadduser) File /usr/local/zope/lib/python/Products/PythonScripts/PythonScript.py, line 302, in _exec (Object: vadduser) (Info: ({'script': <PythonScript instance at 9988900>, 'context': <Folder instance at 9372fb8>, 'container': <Folder instance at 9372fb8>, 'traverse_subpath': []}, ('test1', 'is.lg.ua', '12345678'), {}, None)) File Script (Python), line 2, in vadduser File /usr/local/zope/lib/python/Products/ExternalMethod/ExternalMethod.py, line 198, in __call__ (Object: addVpopmailUser) (Info: (('test1', 'is.lg.ua', '12345678'), {}, None)) File /usr/local/zope/Extensions/Billing.py, line 72, in addVpopmailUser File /usr/local/zope/lib/python/xmlrpclib.py, line 547, in __call__ File /usr/local/zope/lib/python/xmlrpclib.py, line 630, in __request File /usr/local/zope/lib/python/xmlrpclib.py, line 585, in request File /usr/local/zope/lib/python/xmlrpclib.py, line 601, in parse_response File /usr/local/zope/lib/python/xmlrpclib.py, line 371, in close Fault: (see above) N.B. When I change ext. methods on comp A Zope so that they don't return anything it work's OK. example(on comp A) - old: Doesn't work def vadduser(username, domain, password): return vpopmail.vadduser(username, domain, password, "", 0) new: Works def vadduser(username, domain, password): vpopmail.vadduser(username, domain, password, "", 0) But I need get the result codes. Please help me with this question, I'm stuck with it. Best regards, Ruslan mailto:alienoid@is.lg.ua
Whats the error type and value? xmlrpc cannot marshal "None" so if you return a structure with None in it you get an error, one of these appears in your traceback. (Info: (('test1', 'is.lg.ua', '12345678'), {}, None)) -- Andy McKay Agmweb Consulting http://www.agmweb.ca ----- Original Message ----- From: "Ruslan Spivak" <alienoid@is.lg.ua> To: <zope@zope.org> Sent: Tuesday, September 03, 2002 6:46 AM Subject: [Zope] Help: XMLRPC question
Hello zope users,
I have comp A Zope and comp B Zope on LAN.
I've wrote python wrappers for vpopmail API (vadduser, vdeluser, vpasswd), compiled it into .so module, put it into comp A Zope ../zope/lib/python2.1/site-packages and restarted zope.
Here are my external methods on comp A Zope:
import vpopmail # my wrapper module for vpopmail
def vadduser(username, domain, password): return vpopmail.vadduser(username, domain, password, "", 0)
def vdeluser(username, domain): return vpopmail.vdeluser(username, domain)
def vpasswd(username, domain, password): return vpopmail.vpasswd(username, domain, password, 0)
It works OK, each method return 1 if OK and 0 if Error
Problem begins when I begin to call these external methods from comp B Zope using XML-RPC.
Comp B Zope external methods
from xmlrpclib import Server
def vadduser(username, domain, password): s = Server(http://server/vpopmail) return s.vadduser(username, domain, password)
.....
So I can get results (0 or 1) from calling ext. methods from comp A
The problem is that it works and sometimes doesn't work. Often I get error on comp B Zope:
Traceback (innermost last): File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 150, in publish_module File /usr/local/zope/lib/python/Products/Localizer/__init__.py, line 65, in new_publish File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 114, in publish File /usr/local/zope/lib/python/Zope/__init__.py, line 159, in zpublisher_exception_hook (Object: vpopmail) File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 98, in publish File /usr/local/zope/lib/python/ZPublisher/mapply.py, line 88, in mapply (Object: vadduser) File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 39, in call_object (Object: vadduser) File /usr/local/zope/lib/python/Shared/DC/Scripts/Bindings.py, line 252, in __call__ (Object: vadduser) File /usr/local/zope/lib/python/Shared/DC/Scripts/Bindings.py, line 283, in _bindAndExec (Object: vadduser) File /usr/local/zope/lib/python/Products/PythonScripts/PythonScript.py, line 302, in _exec (Object: vadduser) (Info: ({'script': <PythonScript instance at 9988900>, 'context': <Folder instance at 9372fb8>, 'container': <Folder instance at 9372fb8>, 'traverse_subpath': []}, ('test1', 'is.lg.ua', '12345678'), {}, None)) File Script (Python), line 2, in vadduser File /usr/local/zope/lib/python/Products/ExternalMethod/ExternalMethod.py, line 198, in __call__ (Object: addVpopmailUser) (Info: (('test1', 'is.lg.ua', '12345678'), {}, None)) File /usr/local/zope/Extensions/Billing.py, line 72, in addVpopmailUser File /usr/local/zope/lib/python/xmlrpclib.py, line 547, in __call__ File /usr/local/zope/lib/python/xmlrpclib.py, line 630, in __request File /usr/local/zope/lib/python/xmlrpclib.py, line 585, in request File /usr/local/zope/lib/python/xmlrpclib.py, line 601, in parse_response File /usr/local/zope/lib/python/xmlrpclib.py, line 371, in close Fault: (see above)
N.B. When I change ext. methods on comp A Zope so that they don't return anything it work's OK. example(on comp A) - old: Doesn't work
def vadduser(username, domain, password): return vpopmail.vadduser(username, domain, password, "", 0)
new: Works
def vadduser(username, domain, password): vpopmail.vadduser(username, domain, password, "", 0)
But I need get the result codes.
Please help me with this question, I'm stuck with it.
Best regards, Ruslan mailto:alienoid@is.lg.ua
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
On Tue, Sep 03, 2002 at 06:59:59AM -0700, Andy McKay wrote:
Whats the error type and value? xmlrpc cannot marshal "None" so if you return a structure with None in it you get an error, one of these appears in your traceback.
Recent version of Zope marshall None as boolean false. What version of Zope is the XML-RPC server using? -- Martijn Pieters | Software Engineer mailto:mj@zope.com | Zope Corporation http://www.zope.com/ | Creators of Zope http://www.zope.org/ ---------------------------------------------
On Tuesday 03 Sep 2002 3:16 pm, Martijn Pieters wrote:
On Tue, Sep 03, 2002 at 06:59:59AM -0700, Andy McKay wrote:
Whats the error type and value? xmlrpc cannot marshal "None" so if you return a structure with None in it you get an error, one of these appears in your traceback.
Recent version of Zope marshall None as boolean false. What version of Zope is the XML-RPC server using?
since 2.5 (i think) will marshall a return value that is simply 'None'. 2.6 is the first version to apply the same logic if None appears inside a data structure.
On Tue, Sep 03, 2002 at 04:46:24PM +0300, Ruslan Spivak wrote: [Snipped traceback]
Fault: (see above)
The traceback isn't very useful, it only shows that an XML-RPC fault was raised at the XML-RPC server. To diagnose the problem, you'd have to figure out what the fault is.
N.B. When I change ext. methods on comp A Zope so that they don't return anything it work's OK. example(on comp A) - old: Doesn't work
def vadduser(username, domain, password): return vpopmail.vadduser(username, domain, password, "", 0)
new: Works
def vadduser(username, domain, password): vpopmail.vadduser(username, domain, password, "", 0)
But I need get the result codes.
This sound like there sometimes is not an integer return code, and whatever *is* returned cannot be marshalled into an XML-RPC result. You'll need to try and catch the XML-RPC Fault on the client side, and examine its contents (see xmlrpclib.py for what attributes the object will have); or you'll need to log whatever your wrapped extension library returns when the fault occurs. Maybe a try - except on the server side with exception logging would help, with an assert that the return code is indeed either 0 or 1. -- Martijn Pieters | Software Engineer mailto:mj@zope.com | Zope Corporation http://www.zope.com/ | Creators of Zope http://www.zope.org/ ---------------------------------------------
participants (4)
-
Andy McKay -
Martijn Pieters -
Ruslan Spivak -
Toby Dickenson