Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 404f8d8fe7
Fetching contributors…

Cannot retrieve contributors at this time

file 216 lines (145 sloc) 5.067 kb

Documentation for pyramid_xmlrpc

XML-RPC support for the :mod:`pyramid` web framework.

:mod:`pyramid_xmlrpc` Installation

:mod:`pyramid_xmlrpc` is a package that ships outside the main :mod:`pyramid` distribution. To install the package, use easy_install:

easy_install pyramid_xmlrpc

Or obtain the packge via http://github.com/Pylons/pyramid_xmlrpc and use setup.py install.

:mod:`pyramid_xmlrpc` Usage

XML-RPC allows you to expose one or more methods at a particular URL. :mod:`pyramid_xmlrpc` has a simple usage pattern for exposing a single method at a particular url, and a more complicated one for when you want to expose multiple methods at a particular URL.

Exposing a single method

Create a function in the form below. The function will be meant to be called with positional parameters from an XML-RPC request.

Then add the :func:`~pyramid_xmlrpc.xmlrpc_view` decorator to the function.

Then configure your application registry to point to the say_hello view.

Using imperative code in your application's startup configuration:

Using ZCML:

Or using a view_config decorator:

Then call the function via an XML-RPC client. Note that any XML-RPC methodName will be ignored; you must point the client directly at the view URL; traversal doesn't work from there.

Exposing multiple methods

If you have multiple methods to expose at a particular url, you should group them together in a class. Think of this class in the same way as you would when you implement a normal :mod:`pyramid` view as a class rather than a function.

The methods of the class will be those exposed as methods to XML-RPC. Not that XML-RPC only supports positional parameters.

To make this view class handle incoming XML-RPC requests, you simply need to subclass the :class:`~pyramid_xmlrpc.XMLRPCView` class. :class:`~pyramid_xmlrpc.XMLRPCView` provides a :meth:`~pyramid_xmlrpc.XMLRPCView.__call__` method, so make sure that your class doesn't provide one!

For example:

This class can then be registered with :mod:`pyramid` as a normal view.

Using imperative code in your application's startup configuration:

Via ZCML:

The methods exposed by this view can now be used by any XML-RPC client:

Configuration XML-RPC

XML RPC serialization can be configured as in the Python Standard Library.

  • nil xml rpc extension
  • cast every xmlrpc datetime.iso8601 to python datetime.datetime type
  • use an xml encoding in the response

These parameters are set in the :mod:`pyramid` .ini configuration file like below:

[app:main]

pyramid.includes =
  pyramid_xmlrpc

xmlrpc.encoding = utf-8
xmlrpc.allow_none = True
xmlrpc.datetime = True

API Documentation for :mod:`pyramid_xmlrpc`

Indices and tables

Something went wrong with that request. Please try again.