[Zope] vcXMLRPC with Zope?

Brad Clements bkc@murkworks.com
Thu, 05 Dec 2002 11:55:22 -0500


> I've a python script that works nicely from python xmlrpclib client. I'd
> like to use it to work from the browser, preferably using vcXMLRPC library
> ( www.vcdn.org/Public/XMLRPC/).

You should have also posted your python script.

I don't use the the getService method in vcXMLRPC, my javascript code is below..

Zope's xmlrpc needs an exact argument count match to call a PythonScript.

So, all of my Python Scripts take two arguments:

rqType="", rqDict={}

where rqType is a string, and rqDict is a variable argument list.


Here's some javascript code:


    oStruct = {
      orgid:currentOrgID,
      profiletype:profiletype,
      profile:selectedValue,
      instanceDict:handler.getInstanceDict()
    }
    updateButtonObject.disabled = true;
    try {
        result = XMLRPC.call(OrgBaseURL,OrgBaseProcessRequest,"SelectProfile",oStruct);
        if(result != "true") 
             alert(result);
        else  {
             loadProfilesForOrg(currentOrgID);
        }
    }
    catch(err) {
        if(err instanceof Error)
            alert("Unexpected Error Org UpdateProfile:"+err.message);
        else
            alert("Unexpected Error Org UpdateProfile:"+err);
    }


oStruct ends up in rqDict in the Pythonscript, and rqType == 'SelectProfile'

OrgBaseURL and stuff is set like this:

var OrgBaseURL='<dtml-var "Orgs.absolute_url()">';
var OrgBaseProcessRequest = "Orgs.XMLRPCRequest_py";

Note that my javascript file is a DTML method.

XMLRPCRequest_py is the PythonScript id





Brad Clements,                bkc@murkworks.com   (315)268-1000
http://www.murkworks.com                          (315)268-9812 Fax
AOL-IM: BKClements