You are not logged in Log in Join
You are here: Home » Members » Chui Tey » XMLRPC - study the source

Log in
Name

Password

 

XMLRPC - study the source

Preface

Alright, this is not a How To. Its more of a small tour of the Zope source. We will be looking at how ZPublisher implements the xmlrpc magic.

The source I'm referring to is based on Zope 2.3.1

ZPublisher/HTTPRequest.py

Have a look at def processInputs. See where it says fs=FieldStorage(...? This routine processes normal cgi forms, and stores this in the variable fs.

Now XMLRPC arguments are not parsed by FieldStorage, so that falls into the procedure below, and parses an xmlrpc call into method and arguments. At this stage, remember that XMLRPC arguments are positional, and not by keywords.

Since XMLRPC calls have no keywords, ZPublisher can't bind the arguments against variable names. So if you have a look at the REQUEST variable, it doesn't contain the parameters you passed.

At the end of processInputs,

HTTPRequest.other['PATH_INFO'] = XMLRPC method path, eg. http://yourhost/yourObject/yourMethodName

HTTPRequest.args = XMLRPC arguments (as a tuple) eg. (15, MyID)

ZPublisher/publish.py

Now we fast forward to publish.py, where yourhost/yourObject/yourMethod is about to get published via xmlrpc.

Search for result=mapply(..., and ZPublisher has resolved the PATH_INFO into an object and does a complicated version of the standard python apply function.

ZPublisher/mapply.py

The function signature for mapply is as follows:

   def mapply(object, positional=(), keyword={},
           debug=None, maybe=None,
           missing_name=default_missing_name,
           handle_class=default_handle_class,
           context=None, bind=0,   
   

Note that the REQUEST.args is passed in as positional parameters, while REQUEST is passed in as a dictionary.

If you are calling a pythonscript or external method, then positional parameters of the function is lined up with the parameters passed in from the REQUEST.

If you are calling a DTML method, however, things are a bit different.