XML-RPC

Description

Using XML-RPC remote call protocol to manipulate Plone site.

Introduction

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

  • transmogrifier.ploneremote

Authentication

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()

ZPublisher client

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.

Web Services API for Plone (wsapi4plone)

This is an add-on product exposes more methods available through Zope's XML-RPC api.

Importing an Image Using WSAPI

In the following example we retrieve, 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.