Description
Using XML-RPC remote call protocol to manipulate Plone site.
Zope provides transparent XML-RPC support for any traversable object.
Example:
# URL to the object
target = 'http://localhost:8080/plone'
# Call remote method
path = xmlrpclib.ServerProxy(target).getPhysicalPath()
Warning
Zope object handles are not transferable across function call boundaries. Thus, you can only call functions with primitive arguments. If you need to call function with object arguments you need to create server side helper code first.
For more information see
The simplest way to authenticate the user for XML-RPC calls is to embed HTTP Basic Auth data to URL:
# URL to the object
target = 'http://admin:admin@localhost:8080/plone'
# Call remote method
path = xmlrpclib.ServerProxy(target).getPhysicalPath()
XML-RPC does not marshal objects reliable between remote calls. Getting the real remote object can be done with ZPublisher.Client.Object.
Note
This approach works only for Python clients and needs Zope libraries available at the client side.
Warning
Zope object handles are not transferable across function call boundaries. Thus, you can only call functions with primitive arguments. If you need to call function with object arguments you need to create server side helper code first.
This is an add-on product exposes more methods available through Zope's XML-RPC api.
In the following example we retreive, from the 'Pictures' folder, an image called 'red-wine-glass.jpg', post it to a folder called 'ministries' and give it the name 'theimage'.
import os
from xmlrpclib import ServerProxy
from xmlrpclib import Binary
client = ServerProxy("http://username:password@localhost:8080/path/to/plone")
data = open(os.path.join('Pictures', 'red-wine-glass.jpg')).read()
myimage = {'ministries/theimage': [{'title': 'a beautiful wine glass', 'image':Binary(data)},'Image']}
output = client.get_object(client.post_object(myimage))
For more information see wsapi4plone.core add-on product adds XML-RPC operations support for Plone.
The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed.
For basic information about updating this manual and Sphinx format please see Writing and updating the manual guide.